
C Run-Time Libraries (CRT)
The following libraries contain the C run-time library functions.
|
C run-time library (without iostream or standard C++ library)
|
Associated DLL
|
Characteristics
|
Option
|
Preprocessor directives
|
| libcmt.lib | None, static link. | Multithreaded, static link | /MT | _MT |
| msvcrt.lib | msvcr80.dll | Multithreaded, dynamic link (import library for MSVCR80.DLL). Be aware that if you use the Standard C++ Library, your program will need MSVCP80.DLL to run. | /MD | _MT, _DLL |
| libcmtd.lib | None, static link | Multithreaded, static link (debug) | /MTd | _DEBUG, _MT |
| msvcrtd.lib | msvcr80d.dll | Multithreaded, dynamic link (import library for MSVCR80D.DLL) (debug). | /MDd | _DEBUG, _MT, _DLL |
| msvcmrt.lib | msvcm80.dll | C Runtime import library. Used for mixed managed/native code. | /clr | |
| msvcurt.lib | msvcm80.dll | C Runtime import library compiled as 100% pure MSIL code. All code complies with the ECMA URT spec for MSIL. | /clr:pure | |
Note |
|---|
| The single-threaded CRT (libc.lib, libcd.lib) (formerly the /ML or /MLd options) is no longer available. Instead, use the multithreaded CRT. See Multithreaded Libraries Performance. |
If you link your program from the command line without a compiler option that specifies a C run-time library, the linker will use LIBCMT.LIB. This is different from previous versions of Visual C++ which used LIBC.LIB, the single-threaded library, instead.
Using the statically linked CRT implies that any state information saved by the C runtime library will be local to that instance of the CRT. For example, if you use strtok, _strtok_l, wcstok, _wcstok_l, _mbstok, _mbstok_l when using a statically linked CRT, the position of the strtok parser is unrelated to the strtok state used in code in the same process (but in a different DLL or EXE) that is linked to another instance of the static CRT. In contrast, the dynamically linked CRT shares state for all code within a process that is dynamically linked to the CRT. This concern does not apply if you use the new more secure versions of these functions; for example, strtok_s does not have this problem.
Because a DLL built by linking to a static CRT will have its own CRT state, it is not recommended to link statically to the CRT in a DLL unless the consequences of this are specifically desired and understood. For example, if you call _set_se_translator in an executable that loads the DLL linked to its own static CRT, any hardware exceptions generated by the code in the DLL will not be caught by the translator, but hardware exceptions generated by code in the main executable will be caught.
If you are using the /clr compiler switch, your code will be linked with an import library, msvcmrt.lib. The import library references a new library, msvcm80.dll, which provides a proxy between your managed code and the native CRT. You cannot use the statically linked CRT ( /MT or /MTd options) with /clr. Use the dynamically-linked libraries (/MD or /MDd) instead.
If you are using the /clr:pure compiler switch, your code will be linked with the import library msvcurt.lib, which also references msvcm80.dll. As with /clr, you cannot link with the statically linked library.
For more information on using the CRT with /clr, see Mixed (Native and Managed) Assemblies; for /clr:pure, see Pure and Verifiable Code.
To build a debug version of your application, the _DEBUG flag must be defined and the application must be linked with a debug version of one of these libraries. For more information about using the debug versions of the library files, see CRT Debugging Techniques.
This version of Visual C++ is not conformant with the C99 standard.