/MD, /MT, /LD (Use runtime library)
Indicates whether a multithreaded module is a DLL and specifies retail or debug versions of the runtime library.
Syntax
/MD[d]
/MT[d]
/LD[d]
Remarks
Option | Description |
---|---|
/MD | Use the multithread-specific and DLL-specific version of the runtime library. Defines _MT and _DLL . The linker uses the MSVCRT.lib import library to resolve runtime symbols. |
/MDd | Use the debug multithread-specific and DLL-specific version of the runtime library. Defines _DEBUG , _MT , and _DLL . The linker uses the MSVCRTD.lib import library to resolve runtime symbols. |
/MT | Use the multithread, static version of the runtime library. Defines _MT . The linker uses LIBCMT.lib to resolve runtime symbols. |
/MTd | Use the debug multithread, static version of the runtime library. Defines _DEBUG and _MT . The linker uses LIBCMTD.lib to resolve runtime symbols. |
/LD | Create a DLL. Passes the /DLL option to the linker. The linker looks for, but does not require, a DllMain function. If you don't 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 (Name EXE File) as naming a DLL rather than an .exe file. By default, the program name becomes basename.dll instead of basename.exe.Implies /MT unless you explicitly specify /MD. |
/LDd | Create a debug DLL. Defines _MT and _DEBUG . |
For more information about C runtime libraries and which libraries are used when you compile with /clr (Common Language Runtime Compilation), see CRT Library Features.
All modules passed to a given invocation of the linker must have been compiled with the same runtime library compiler option (/MD, /MT, /LD).
For more information about how to use the debug versions of the runtime libraries, see C runtime Library Reference.
For more about DLLs, see Create C/C++ DLLs in Visual Studio.
To set this compiler option in the Visual Studio development environment
- Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.
- Select the Configuration Properties > C/C++ > Code Generation property page.
- Modify the Runtime Library property.
To set this compiler option programmatically
- See RuntimeLibrary.
See also
MSVC Compiler Options
MSVC Compiler Command-Line Syntax
The Great C Runtime (CRT) Refactoring