Skip to content

Commit dc0bd65

Browse files
authored
Merge pull request #3429 from TylerMSFT/twhitney-perfwork
fixes to improve topic performance
2 parents f69713f + 1d746ab commit dc0bd65

File tree

4 files changed

+46
-43
lines changed

4 files changed

+46
-43
lines changed

docs/c-runtime-library/c-run-time-library-reference.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
---
22
title: "C runtime library reference"
33
description: "Links to information and reference for the Microsoft C runtime library functions."
4-
ms.date: "10/05/2020"
4+
ms.date: "3/5/2021"
55
f1_keywords: ["c.runtime"]
66
helpviewer_keywords: ["CRT", "runtime libraries", "CRT, reference"]
7-
ms.assetid: a503e11c-8dca-4846-84fb-025a826c32b8
87
---
9-
# C runtime Library Reference
8+
# Microsoft C runtime library (CRT) reference
109

11-
The Microsoft runtime library provides routines for programming for the Microsoft Windows operating system. These routines automate many common programming tasks that are not provided by the C and C++ languages.
10+
The Microsoft runtime library provides routines for programming the Microsoft Windows operating system. These routines automate many common programming tasks that are not provided by the C and C++ languages.
1211

1312
Sample programs are included in the individual reference topics for most routines in the library.
1413

1514
## In This Section
1615

17-
[C Runtime libraries](crt-library-features.md)\
18-
Discusses the .lib files that comprise the C runtime libraries.
19-
2016
[Universal C runtime routines by category](run-time-routines-by-category.md)\
2117
Provides links to the runtime library by category.
2218

@@ -41,6 +37,9 @@ Provides links to the C runtime library functions, organized by function family.
4137
[Language and country/region strings](locale-names-languages-and-country-region-strings.md)\
4238
Describes how to use the `setlocale` function to set the language and Country/Region strings.
4339

40+
[C runtime (CRT) and C++ Standard Library `.lib` files](crt-library-features.md)\
41+
Discusses the `.lib` files that make up the C runtime libraries and their associated compiler options and preprocessor directives.
42+
4443
## Related Sections
4544

4645
[Debug routines](debug-routines.md)\
Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
---
2-
title: "CRT Library Features"
3-
description: "List of files that contain the Microsoft C run-time libraries, and their associated compiler options and preprocessor directives."
4-
ms.date: 09/03/2020
5-
ms.topic: "conceptual"
2+
title: "C runtime (CRT) and C++ Standard Library .lib files"
3+
description: "List of Microsoft C runtime and C++ Standard Library .lib files that you can link against and their associated compiler options and preprocessor directives."
4+
ms.date: "3/5/2021"
5+
ms.topic: "reference"
66
helpviewer_keywords: ["MSVCR71.dll", "libraries [C++], multithreaded", "library files, run-time", "LIBCMT.lib", "LIBCP.lib", "LIBCPMT.lib", "run-time libraries, C", "CRT, release versions", "MSVCP71.dll", "LIBC.lib", "libraries [C++]", "libraries [C++], run-time", "linking [C++], libraries"]
7-
ms.assetid: a889fd39-807d-48f2-807f-81492612463f
87
---
9-
# CRT Library Features
8+
# C runtime (CRT) and C++ Standard Library `.lib` files
109

11-
This topic discusses the various .lib files that comprise the C run-time libraries as well as their associated compiler options and preprocessor directives.
10+
This topic lists the Microsoft C runtime library `.lib` files that you can link against when you develop your application, and their associated compiler options and preprocessor directives.
1211

13-
## C Run-Time Libraries (CRT)
12+
See [Redistributing Visual C++ files](../windows/redistributing-visual-cpp-files.md) if you're looking for information about deploying the C runtime files necessary to support your application.
1413

15-
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.
14+
See [C runtime library reference](../c-runtime-library/c-run-time-library-reference.md) if you're looking for API reference for the C runtime library.
15+
16+
## C runtime `.lib` files
17+
18+
The C runtime Library (CRT) is the part of the C++ Standard Library that incorporates the ISO C 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.
1619

1720
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](../windows/redistributing-visual-cpp-files.md).
1821

@@ -25,7 +28,7 @@ The following table lists the libraries that implement the UCRT.
2528
| *`ucrt.lib`* | *`ucrtbase.dll`* | DLL import library for the UCRT. | **`/MD`** | `_MT`, `_DLL` |
2629
| *`ucrtd.lib`* | *`ucrtbased.dll`* | DLL import library for the Debug version of the UCRT. Not redistributable. | **`/MDd`** | `_DEBUG`, `_MT`, `_DLL` |
2730

28-
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.
31+
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. The vcruntime library version needs to match the version of the compiler you're using.
2932

3033
This table lists the libraries that implement the vcruntime library.
3134

@@ -37,10 +40,10 @@ This table lists the libraries that implement the vcruntime library.
3740
| *`vcruntimed.lib`* | *`vcruntime<version>d.dll`* | DLL import library for the Debug vcruntime. Not redistributable. | **`/MDd`** | `_DEBUG`, `_MT`, `_DLL` |
3841

3942
> [!NOTE]
40-
> When the UCRT refactoring occurred, the Concurrency Runtime functions were moved into
41-
*`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.
43+
> When the UCRT was refactored, the Concurrency Runtime functions were moved into
44+
*`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 doesn't have condition variables.
4245

43-
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.
46+
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's specific to the version of the compiler used. This library is always statically linked, even when using a dynamically linked UCRT.
4447

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

@@ -55,21 +58,21 @@ This table lists the libraries that implement CRT initialization and termination
5558
| *`msvcurt.lib`* | **Deprecated** Static library for the pure managed CRT. | **`/clr:pure`** | |
5659
| *`msvcurtd.lib`* | **Deprecated** Static library for the Debug version of the pure managed CRT. Not redistributable. | **`/clr:pure`** | |
5760

58-
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`*.
61+
If you link your program from the command line without a compiler option that specifies a C runtime library, the linker will use the statically linked CRT libraries: *`libcmt.lib`*, *`libvcruntime.lib`*, and *`libucrt.lib`*.
5962

60-
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`](../c-runtime-library/reference/strtok-strtok-l-wcstok-wcstok-l-mbstok-mbstok-l.md) 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.
63+
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`](../c-runtime-library/reference/strtok-strtok-l-wcstok-wcstok-l-mbstok-mbstok-l.md) 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 doesn't apply if you use the new more secure versions of these functions; for example, `strtok_s` doesn't have this problem.
6164

62-
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`](../c-runtime-library/reference/set-se-translator.md) 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.
65+
Because a DLL built by linking to a static CRT has its own CRT state, it isn't 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`](../c-runtime-library/reference/set-se-translator.md) 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.
6366

64-
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.
67+
If you're 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.
6568

6669
For more information on using the CRT with **`/clr`**, see [Mixed (Native and Managed) Assemblies](../dotnet/mixed-native-and-managed-assemblies.md).
6770

6871
To build a debug version of your application, the [`_DEBUG`](../c-runtime-library/debug.md) 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](/visualstudio/debugger/crt-debugging-techniques).
6972

70-
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.
73+
This version of the CRT isn't fully conformant with the C99 standard. In versions before Visual Studio 2019 version 16.8, the \<tgmath.h> header isn't supported. In all versions, the `CX_LIMITED_RANGE` and `FP_CONTRACT` pragma macros aren't 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.
7174

72-
## C++ Standard Library
75+
## C++ Standard Library `.lib` files
7376

7477
| C++ Standard Library | Characteristics | Option | Preprocessor directives |
7578
|--|--|--|--|
@@ -78,17 +81,17 @@ This version of the CRT is not fully conformant with the C99 standard. In versio
7881
| *`libcpmtd.lib`* | Multithreaded, static link | **`/MTd`** | `_DEBUG`, `_MT` |
7982
| *`msvcprtd.lib`* | Multithreaded, dynamic link (import library for *`msvcp<version>d.dll`*) | **`/MDd`** | `_DEBUG`, `_MT`, `_DLL` |
8083

81-
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](../standard-library/cpp-standard-library-header-files.md) in your code, a C++ Standard Library will be linked in automatically by Visual C++ at compile time. For example:
84+
When you build a release version of your project, one of the basic C runtime 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](../standard-library/cpp-standard-library-header-files.md) in your code, a C++ Standard Library will be linked automatically by Visual C++ at compile time. For example:
8285

8386
```cpp
8487
#include <ios>
8588
```
8689

87-
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.
90+
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 Application Binary Interface (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.
8891

8992
## What problems exist if an application uses more than one CRT version?
9093

91-
Every executable image (EXE or DLL) can have its own statically linked CRT, or can dynamically link to a CRT. The version of the CRT statically included in or dynamically loaded by a particular image depends on the version of the tools and libraries it was built with. A single process may load multiple EXE and DLL images, each with its own CRT. Each of those CRTs may use a different allocator, may have different internal structure layouts, and may use different storage arrangements. This means that allocated memory, CRT resources, or classes passed across a DLL boundary can cause problems in memory management, internal static usage, or layout interpretation. For example, if a class is allocated in one DLL but passed to and deleted by another, which CRT deallocator is used? The errors caused can range from the subtle to the immediately fatal, and therefore direct transfer of such resources is strongly discouraged.
94+
Every executable image (EXE or DLL) can have its own statically linked CRT, or can dynamically link to a CRT. The version of the CRT statically included in or dynamically loaded by a particular image depends on the version of the tools and libraries it was built with. A single process may load multiple EXE and DLL images, each with its own CRT. Each of those CRTs may use a different allocator, may have different internal structure layouts, and may use different storage arrangements. This means allocated memory, CRT resources, or classes passed across a DLL boundary can cause problems in memory management, internal static usage, or layout interpretation. For example, if a class is allocated in one DLL but passed to and deleted by another, which CRT deallocator is used? The errors caused can range from the subtle to the immediately fatal, and therefore direct transfer of such resources is strongly discouraged.
9295

9396
You can avoid many of these issues by using Application Binary Interface (ABI) technologies instead, as they are designed to be stable and versionable. Design your DLL export interfaces to pass information by value, or to work on memory that is passed in by the caller rather than allocated locally and returned to the caller. Use marshaling techniques to copy structured data between executable images. Encapsulate resources locally and only allow manipulation through handles or functions you expose to clients.
9497

@@ -98,4 +101,5 @@ Be careful if your program passes certain CRT resources across DLL boundaries. R
98101

99102
## See also
100103

101-
- [C Run-Time Library Reference](../c-runtime-library/c-run-time-library-reference.md)
104+
- [C runtime library reference](../c-runtime-library/c-run-time-library-reference.md)
105+
- [Redistributing Visual C++ Files](../windows/redistributing-visual-cpp-files.md)

docs/c-runtime-library/toc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
- name: CRT library features
44
expanded: false
55
items:
6-
- name: CRT library features
7-
href: ../c-runtime-library/crt-library-features.md
86
- name: Compatibility
97
expanded: false
108
items:
@@ -66,6 +64,8 @@
6664
href: ../c-runtime-library/global-state.md
6765
- name: Type-generic math
6866
href: ../c-runtime-library/tgmath.md
67+
- name: C runtime (CRT) and C++ Standard Library .lib files
68+
href: ../c-runtime-library/crt-library-features.md
6969
- name: Universal C runtime routines by category
7070
expanded: false
7171
items:

0 commit comments

Comments
 (0)