zoukankan      html  css  js  c++  java
  • CRT

    https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library

    For more information about C run-time 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 run-time library compiler option (/MD, /MT, /LD).

    For more information about how to use the debug versions of the run-time libraries, see C Run-Time Library Reference.

    For more about DLLs, see Create C/C++ DLLs in Visual Studio.

    OptionDescription
    /MD Causes the application to use the multithread-specific and DLL-specific version of the run-time library. Defines _MT and _DLL and 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 enables the linker to resolve external references. The actual working code is contained in MSVCRversionnumber.DLL, which must be available at run time to applications linked with MSVCRT.lib.
    /MDd 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 name MSVCRTD.lib into the .obj file.
    /MT Causes the application to use the multithread, static version of the run-time library. Defines _MT and 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.
    /MTd Defines _DEBUG and _MT. 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.
    /LD 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 (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 Creates a debug DLL. Defines _MT and _DEBUG.

    https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features

    C Run-Time Libraries (CRT)

    The C Run-time Library (CRT) is the part of the C++ Standard Library that incorporates the ISO C99 standard library. The Visual C++ libraries that implement the CRT support native code development, and both mixed native and managed code. All versions of the CRT support multi-threaded development. Most of the libraries support both static linking, to link the library directly into your code, or dynamic linking to let your code use common DLL files.

    Starting in Visual Studio 2015, the CRT has been refactored into new binaries. The Universal CRT (UCRT) contains the functions and globals exported by the standard C99 CRT library. The UCRT is now a Windows component, and ships as part of Windows 10. The static library, DLL import library, and header files for the UCRT are now found in the Windows 10 SDK. When you install Visual C++, Visual Studio setup installs the subset of the Windows 10 SDK required to use the UCRT. You can use the UCRT on any version of Windows supported by Visual Studio 2015 and later versions. You can redistribute it using vcredist for supported versions of Windows other than Windows 10. For more information, see Redistributing Visual C++ Files.

    The following table lists the libraries that implement the UCRT.

    C Run-Time Libraries (CRT)
    LibraryAssociated DLLCharacteristicsOptionPreprocessor directives
    libucrt.lib None Statically links the UCRT into your code. /MT _MT
    libucrtd.lib None Debug version of the UCRT for static linking. Not redistributable. /MTd _DEBUG, _MT
    ucrt.lib ucrtbase.dll DLL import library for the UCRT. /MD _MT, _DLL
    ucrtd.lib ucrtbased.dll DLL import library for the Debug version of the UCRT. Not redistributable. /MDd _DEBUG, _MT, _DLL

    The vcruntime library contains Visual C++ CRT implementation-specific code, such as exception handling and debugging support, runtime checks and type information, implementation details and certain extended library functions. This library is specific to the version of the compiler used.

    This table lists the libraries that implement the vcruntime library.

    Table 2
    LibraryAssociated DLLCharacteristicsOptionPreprocessor directives
    libvcruntime.lib None Statically linked into your code. /MT _MT
    libvcruntimed.lib None Debug version for static linking. Not redistributable. /MTd _MT, _DEBUG
    vcruntime.lib vcruntime<version>.dll DLL import library for the vcruntime. /MD _MT, _DLL
    vcruntimed.lib vcruntime<version>d.dll DLL import library for the Debug vcruntime. Not redistributable. /MDd _DEBUG, _MT, _DLL

    Note

    When the UCRT refactoring occurred, the Concurrency Runtime functions were moved into concrt140.dll, which was added to the C++ redistributable package. This DLL is required for C++ parallel containers and algorithms such as concurrency::parallel_for. In addition, the C++ Standard Library requires this DLL on Windows XP to support synchronization primitives, because Windows XP does not have condition variables.

    The code that initializes the CRT is in one of several libraries, based on whether the CRT library is statically or dynamically linked, or native, managed, or mixed code. This code handles CRT startup, internal per-thread data initialization, and termination. It is specific to the version of the compiler used. This library is always statically linked, even when using a dynamically linked UCRT.

    This table lists the libraries that implement CRT initialization and termination.

    Table 3
    LibraryCharacteristicsOptionPreprocessor directives
    libcmt.lib Statically links the native CRT startup into your code. /MT _MT
    libcmtd.lib Statically links the Debug version of the native CRT startup. Not redistributable. /MTd _DEBUG, _MT
    msvcrt.lib Static library for the native CRT startup for use with DLL UCRT and vcruntime. /MD _MT, _DLL
    msvcrtd.lib Static library for the Debug version of the native CRT startup for use with DLL UCRT and vcruntime. Not redistributable. /MDd _DEBUG, _MT, _DLL
    msvcmrt.lib Static library for the mixed native and managed CRT startup for use with DLL UCRT and vcruntime. /clr  
    msvcmrtd.lib Static library for the Debug version of the mixed native and managed CRT startup for use with DLL UCRT and vcruntime. Not redistributable. /clr  
    msvcurt.lib Deprecated Static library for the pure managed CRT. /clr:pure  
    msvcurtd.lib Deprecated Static library for the Debug version of the pure managed CRT. Not redistributable. /clr:pure  

    If you link your program from the command line without a compiler option that specifies a C run-time library, the linker will use the statically linked CRT libraries: libcmt.lib, libvcruntime.lib, and libucrt.lib.

    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 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 a static library, msvcmrt.lib. The static library 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. The pure managed CRT libraries are deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017.

    For more information on using the CRT with /clr, see Mixed (Native and Managed) Assemblies.

    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 the CRT is not fully conformant with the C99 standard. In versions before Visual Studio 2019 version 16.8, the <tgmath.h> header is not supported. In all versions, the CX_LIMITED_RANGE and FP_CONTRACT pragma macros are not supported. Certain elements such as the meaning of parameter specifiers in standard IO functions use legacy interpretations by default. You can use /Zc compiler conformance options and specify linker options to control some aspects of library conformance.

    C++ Standard Library

    C++ Standard Library
    C++ Standard LibraryCharacteristicsOptionPreprocessor directives
    libcpmt.lib Multithreaded, static link /MT _MT
    msvcprt.lib Multithreaded, dynamic link (import library for msvcp<version>.dll) /MD _MT, _DLL
    libcpmtd.lib Multithreaded, static link /MTd _DEBUG, _MT
    msvcprtd.lib Multithreaded, dynamic link (import library for msvcp<version>d.dll) /MDd _DEBUG, _MT, _DLL

    When you build a release version of your project, one of the basic C run-time libraries (libcmt.lib, msvcmrt.lib, msvcrt.lib) is linked by default, depending on the compiler option you choose (multithreaded, DLL, /clr). If you include one of the C++ Standard Library header files in your code, a C++ Standard Library will be linked in automatically by Visual C++ at compile time. For example:

    C++
    #include <ios>
    

    For binary compatibility, more than one DLL file may be specified by a single import library. Version updates may introduce dot libraries, separate DLLs that introduce new library functionality. For example, Visual Studio 2017 version 15.6 introduced msvcp140_1.dll to support additional standard library functionality without breaking the ABI supported by msvcp140.dll. The msvcprt.lib import library included in the toolset for Visual Studio 2017 version 15.6 supports both DLLs, and the vcredist for this version installs both DLLs. Once shipped, a dot library has a fixed ABI, and will never have a dependency on a later dot library.

  • 相关阅读:
    Saltstack 命令参数整理
    Saltstack 命令行:批量覆盖指定文件
    Nginx + Tomcat Windows下的负载均衡配置
    linux和windows同步数据 cwrsync client to rsync server
    Amoeba for MySQL 非常好用的mysql集群软件
    Ubuntu 下 JDK+Tomcat+MySql 环境的搭建
    Ubuntu server下安装JDK和Tomcat7
    EhCache 分布式缓存/缓存集群
    电商系统中的商品模型的分析与设计
    大型网站架构的演化[转]
  • 原文地址:https://www.cnblogs.com/Searchor/p/14176813.html
Copyright © 2011-2022 走看看