C Runtime Library/MT/MTD/MD/MDD

Source: Internet
Author: User

Reprinted from: http://www.cnblogs.com/eddyshn/archive/2009/11/23/1608823.html

 

 

Multi-threaded VC compilation options (/mt)
Multi-thread debugging (/MTD)
Multi-threaded DLL (/MD)
Multi-thread debugging DLL (/MDD)
C Runtime Library File
Single thread (static link) ml libc. Lib
Debug single thread (static link) MLD libcd. Lib
Multithread (static link) MT libcmt. Lib
Debug multithread (static link) MTD libcmtd. Lib
Multithread (Dynamic Link) MD msvert. Lib
Debug multithread (Dynamic Link) MDD msvertd. Lib
3. Differences between various C Runtime Libraries
(1) Single-threaded library with static links
A single-threaded library with static links can only be used for single-threaded applications. The target code of the C Runtime Library is eventually compiled into the binary file of the application. You can use the/ml compilation option to set a single line using static links in Visual C ++.
Process library.
(2) multi-thread library with static links
The target code of the multi-threaded library with static links is finally compiled into the binary file of the application, but it can be used in multi-threaded programs. You can use the/MT compilation option to set a multi-threaded library that uses static links in Visual C ++.
(3) dynamically linked Runtime Library
The dynamic link Runtime Library saves all c-library functions in a separate dynamic link library msvcrtxx. dll. msvcrtxx. dll handles multithreading issues. You can use the/MD compilation option to set the dynamic usage of Visual C ++.
The linked Runtime Library.
The/MDD,/MLD, or/MTD options use the debug Runtime Library (the runtime function library of the debug version), which corresponds to/MD,/ml, or/MT respectively. The debug Runtime Library contains debugging information.
And uses some protection mechanisms to help identify errors and enhance the detection of errors. Therefore, the running performance is inferior to that of the release version.
The following describes the Visual C ++ compiler options in msdn:
These options select a single-threaded or multi-threaded runtime routine to indicate whether the multi-threaded module is a DLL, and select the release or debug version of The Runtime Library.
Option description
/MD defines _ MT and _ DLL to select the specific multi-thread version and dll version of the runtime routine from the standard. h file at the same time. This option also enables the compiler to put the library name msvcrt. Lib into the. OBJ file.
The application compiled with this option is statically linked to msvcrt. Lib. This library provides a code layer that allows the linker to parse external references. The actual working code is included in msvcr71.dll. This library must be linked to msvcrt. Lib
The connected application is available.
When _ static_cpplib (/d_static_cpplib) is defined and/MD is used, it causes the application to pass through the static multi-threaded Standard C ++ Library (libcpmt. lib) instead of the dynamic version (msvcprt. lib ).
And dynamically link to the master CRT through msvcrt. Lib.
/MDD defines _ debug, _ Mt, and _ DLL to select the debugging multi-thread and DLL-specific versions of the runtime routine from the standard. h file. It also enables the compiler to put the library name msvcrtd. Lib into the. OBJ file.
/Ml causes the compiler to put the library name libc. Lib into the. OBJ file so that the linker can use libc. lib to parse external symbols. This is the default operation of the compiler. Libc. Lib does not support multithreading.
/MLD defines _ debug and causes the compiler to put the library name libcd. Lib into the. OBJ file so that the linker can use libcd. lib to parse external symbols. Libcd. Lib does not support multithreading.
/MT defines _ mt to select a specific multi-thread version of the runtime routine from the Standard Header (. h) file. This option also enables the compiler to put the library name libcmt. Lib into the. OBJ file so that the linker can use libcmt. Lib for parsing.
External symbols. To create a multi-threaded program,/Mt or/MD (or their debugging equivalent options/MTD or/MDD) is required ).
/MTD defines _ debug and _ Mt. Defining _ mt will result in selecting a specific multi-thread version of the runtime routine from the standard. h file. This option also enables the compiler to put the library name libcmtd. Lib into the. OBJ file so that the linker can
Use libcmtd. lib to parse external symbols. To create a multi-threaded program,/MTD or/MDD (or their non-debugging equivalent options/Mt or Md) is required ).
/LD create DLL.
Pass the/DLL option to the linker. The linker searches for the dllmain function, but does not need this function. If the dllmain function is not compiled, the linker inserts the dllmain function that returns true.
Link DLL startup code.
If the Export (. exp) file is not specified on the command line, create the import/export (. Lib); link the import/export link to the application that calls your DLL.
Interpret/Fe as the name DLL rather than the. exe file. By default, the program name is named as the base name. dll, but not the base name. .exe.
If one of the/m options is not explicitly specified, change the default Runtime Library support to/mt.
/LDD create and debug the DLL. Define _ debug.
Warning do not mix the static and dynamic versions of the Runtime Library. There are multiple runtime database copies in a process, which may cause problems because the static data in the copies is not shared with other copies. The linker is not allowed in the. exe file.
You can still use two (or more) Copies of the Runtime Library. For example, when used together with the. exe file linked to the Runtime Library of the dynamic (DLL) version
DLL. (You should also avoid mixing the debug and non-DEBUG Versions of these libraries in a process ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.