views:

26

answers:

1

I have a large body of code, compiled with /MT (i.e. expecting to statically link against the CRT). I need to combine this with a static third-party library, which has been built with /MD (i.e. expecting to link the CRT dynamically).

Is it theoretically possible to link the two into one executable without recompiling either?

If I link with /nodefaultlib:msvcrt, I end up with a small number of undefined references to things like __imp__wgetenv. I'm tempted to try implementing those functions in my own code, forwarding to wgetenv, etc. Is that worth trying, or will I run straight into the next problem?

Unfortunately I'm Forbidden from taking the easy option of packing the thirdparty code into a separate DLL :-/

A: 

No. /MT and /MD are mutually exclusive.

All modules passed to a given invocation of the linker must have been compiled with the same run-time library compiler option (/MD, /MT, /LD).

Source

ChrisF
Not the answer I was hoping for, but thanks ;-)
slowdog