NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

/MD, /ML, /MT, /LD (Use Run-Time Library)

/MD[d]
/ML[d]
/MT[d]
/LD[d]

These options select either single-threaded or multithreaded run-time routines, indicate if a multithreaded module is a DLL, and select retail or debug versions of the runtime library.

Caution   Do not mix static and dynamic versions of the run-time libraries. Having more than one copy of the run-time libraries in a process can cause problems, because static data in one copy is not shared with the other copy. The linker prevents you from linking with both static and dynamic versions within one .exe file, but you can still end up with two (or more) copies of the run-time libraries. For example, a dynamic-link library linked with the static (non-DLL) versions of the run-time libraries can cause problems when used with an .exe file that was linked with the dynamic (DLL) version of the run-time libraries. (You should also avoid mixing the debug and non-debug versions of the libraries in one process.)
Command Line Project Settings Description
/MD Multithreaded DLL Defines _MT and _DLL so that both multithread- and DLL-specific versions of the run-time routines are selected from the standard .h files. This option also causes the compiler to place the library name MSVCRT.lib into the .obj file.
Applications compiled with this option are statically linked to MSVCRT.lib. This library provides a layer of code that allows the linker to resolve external references. The actual working code is contained in MSVCRT.dll, which must be available at run time to applications linked with MSVCRT.lib.
/MDd Debug Multithreaded DLL Defines _DEBUG, _MT, and _DLL so that debug multithread- and DLL-specific versions of the run-time routines are selected from the standard .h files. It also causes the compiler to place the library name MSVCRTD.lib into the .obj file.
/ML Single-Threaded Causes the compiler to place the library name LIBC.lib into the .obj file so that the linker will use LIBC.lib to resolve external symbols. This is the compiler’s default action. LIBC.lib does not provide multithread support.
/MLd Debug Single-Threaded Defines _DEBUG and causes the compiler to place the library name LIBCD.lib into the .obj file so that the linker will use LIBCD.lib to resolve external symbols. LIBCD.lib does not provide multithread support.
/MT Multithreaded Defines _MT so that multithread-specific versions of the run-time routines are selected from the standard header (.h) files. This option also causes the compiler to place the library name LIBCMT.lib into the .obj file so that the linker will use LIBCMT.lib to resolve external symbols. Either /MT or /MD (or their debug equivalents /MTd or /MDd) is required to create multithreaded programs.
/MTd Debug Multithreaded Defines _DEBUG and _MT. Defining _MT causes multithread-specific versions of the run-time routines to be selected from the standard .h files. This option also causes the compiler to place the library name LIBCMTD.lib into the .obj file so that the linker will use LIBCMTD.lib to resolve external symbols. Either /MTd or /MDd (or their non-debug equivalents /MT or MD) is required to create multithreaded programs.
/LD Not applicable Creates a DLL.
Passes the /DLL option to the linker. The linker looks for, but does not require, a DllMain function. If you do not write a DllMain function, the linker inserts a DllMain function that returns TRUE.
Links the DLL startup code.
Creates an import library (.lib), if an export (.exp) file is not specified on the command line; you link the import library to applications that call your DLL.
Interprets /Fe as naming a DLL rather than an .exe file; the default program name becomes basename.dll instead of basename.exe.
Changes default run-time library support to /MT if you have not explicitly specified one of the /M options
/LDd Not applicable Creates a debug DLL. Defines _DEBUG.

For more information on using the debug versions of the run-time libraries, see Run-Time Library Reference.

Knowledge Base article Q140584 also discusses how to choose the appropriate C run-time library.

For further discussion of DLLs, see DLL Topics.

See Also

Compiler Options | Setting Compiler Options