I’m trying to build a C/C++ static library using visual studio 2005. Since the selection of the runtime library is a compile option, I am forced to build four variations of my library, one for each variation of the runtime library:
- /MT – static runtime library
- /MD – DLL runtime library
- /MTd – debug static runtime library
- /MDd – debug DLL runtime library
These are compiler options, not linker options. Coming from a Linux background, this seems strange. Do the different runtime libraries have different calling conventions or something? Why can’t the different runtime libraries be resolved at link time, i.e. when I link the application which uses my static library?
One side effect of the C preprocessor definitions like
_DLLand_DEBUGthat zdan mentioned:Some data structures (such as STL containers and iterators) may be sized differently in the debug runtime, possibly due to features such as
_HAS_ITERATOR_DEBUGGINGand_SECURE_SCL. You must compile your code with structure definitions that are binary-compatible with the library you’re linking to.If you mix and match object files that were compiled against different runtime libraries, you will get linker warnings such as the following: