Visual Studio #
Compiler Options #
In Microsoft Visual Studio compiler, /MD
, /MDd
, /MT
, and /MTd
are options that determine which version of the C++ runtime library to use. Here’s what each of them means:
/MD
: This option causes the application to use the multithread-specific and DLL-specific version of the run-time library. It defines_MT
and_DLL
and causes the compiler to place the library nameMSVCRT.lib
into the.obj
file. Applications compiled with this option are statically linked toMSVCRT.lib
. The actual working code is contained inMSVCR versionnumber .DLL
, which must be available at run time to applications linked withMSVCRT.lib
./MDd
: This option defines_DEBUG
,_MT
, and_DLL
and causes the application to use the debug multithread-specific and DLL-specific version of the run-time library. It also causes the compiler to place the library nameMSVCRTD.lib
into the.obj
file./MT
: This option causes the application to use the multithread, static version of the run-time library. It defines_MT
and causes the compiler to place the library nameLIBCMT.lib
into the.obj
file so that the linker will useLIBCMT.lib
to resolve external symbols./MTd
: This option defines_DEBUG
and_MT
. It also causes the compiler to place the library nameLIBCMTD.lib
into the.obj
file so that the linker will useLIBCMTD.lib
to resolve external symbols.
In general, if you are using DLLs, you should go for the dynamically linked CRT (/MD
). Either /MT
or /MD
(or their debug equivalents /MTd
or /MDd
) is required to create multithreaded programs.