| 1 |
== Summary == |
| 2 |
|
| 3 |
Starting from mingw-w64 version 12 and onwards, UCRT (Universal C Runtime) will |
| 4 |
be the default CRT runtime, unless specified otherwise during the mingw-w64 |
| 5 |
build process. We believe that this configuration is the best choice for the |
| 6 |
majority of users. While we encourage users to consider switching to UCRT, we |
| 7 |
understand that it may not always be desirable, especially for compatibility |
| 8 |
reasons. Therefore, all previously supported configurations will continue to |
| 9 |
be supported. Users who wish to continue using msvcrt.dll can easily do so by |
| 10 |
adding the --with-default-msvcrt=msvcrt argument to both the |
| 11 |
mingw-w64-headers and mingw-w64-crt configure scripts. |
| 12 |
|
| 13 |
|
| 14 |
== Background == |
| 15 |
|
| 16 |
mingw-w64 provides C runtime libraries that directly or indirectly utilize |
| 17 |
Microsoft DLLs at runtime. Over the years, Microsoft has released various |
| 18 |
versions of these DLLs, some of which were designed for specific MSVC versions |
| 19 |
while others aimed for backward compatibility. When building the mingw-w64 |
| 20 |
toolchain, users can specify a version of the runtime DLL using the |
| 21 |
--with-default-msvcrt= configure option. The most commonly used versions are |
| 22 |
ucrt (utilizing UCRT, via api-ms-win-crt-*.dll API set libraries) and |
| 23 |
msvcrt (utilizing msvcrt.dll). |
| 24 |
|
| 25 |
Users can also choose crtdll (utilizing system crtdll.dll library which |
| 26 |
is a predecessor of msvcrt.dll and is available on all 32-bit Windows versions |
| 27 |
starting from NT 3.1, Win32s and Win9x), version-specific msvcr* libraries, |
| 28 |
ucrtbase (linking directly against ucrtbase.dll instead of |
| 29 |
api-ms-win-crt-*.dll wrappers) and debug mode libraries. |
| 30 |
|
| 31 |
The implementation of msvcrt.dll was introduced with Visual C++ 4.2 in 1996. |
| 32 |
As a system library it is included since Windows 98 and NT 4. While it has |
| 33 |
been extended for a period, it eventually became frozen in favor of providing |
| 34 |
separate DLLs for future MSVC versions. Although msvcrt.dll continues to be |
| 35 |
shipped with modern Windows versions, it remains compatible with the version |
| 36 |
from the 1996. msvcrt.dll is known to deviate from standard behavior in many |
| 37 |
aspects. mingw-w64 includes compatibility wrappers and extensions to improve |
| 38 |
standard compatibility, but there are limitations to what can be practically |
| 39 |
achieved. |
| 40 |
|
| 41 |
On the other hand, the UCRT was introduced with MSVC 14 and is currently |
| 42 |
included with all Windows versions supported by Microsoft. It is also available |
| 43 |
as a redistributable package for older versions of Windows. UCRT aims to |
| 44 |
replace MSVC version-specific DLLs and has been used by all MSVC versions since |
| 45 |
its introduction. It offers a more modern approach compared to msvcrt.dll and |
| 46 |
provides better standard compatibility out of the box, reducing overhead on the |
| 47 |
mingw-w64 side. |
| 48 |
|
| 49 |
Windows 10 and newer systems have UCRT automatically preinstalled. |
| 50 |
|
| 51 |
Windows Vista / Server 2008, Windows 7 / Server 2008 R2, Windows 8 / Server 2012 |
| 52 |
and Windows 8.1 / Server 2012 R2 systems include UCRT libraries in KB2999226 |
| 53 |
system update, which is available at website: |
| 54 |
https://support.microsoft.com/help/2999226 |
| 55 |
|
| 56 |
For Windows XP and Windows Server 2003, the UCRT libraries are provided via |
| 57 |
a Visual Studio redistributable package. The latest compatible |
| 58 |
version for these systems is the Visual Studio 2019 16.7 redistributable |
| 59 |
package, it contains UCRT version 14.27.29114.0 and is available at: |
| 60 |
32-bit: https://download.visualstudio.microsoft.com/download/pr/56f631e5-4252-4f28-8ecc-257c7bf412b8/D305BAA965C9CD1B44EBCD53635EE9ECC6D85B54210E2764C8836F4E9DEFA345/VC_redist.x86.exe |
| 61 |
64-bit: https://download.visualstudio.microsoft.com/download/pr/722d59e4-0671-477e-b9b1-b8da7d4bd60b/591CBE3A269AFBCC025681B968A29CD191DF3C6204712CBDC9BA1CB632BA6068/VC_redist.x64.exe |
| 62 |
|
| 63 |
Windows 2000 and older systems do not have support for UCRT at all. |
| 64 |
|
| 65 |
|
| 66 |
== Compatibility == |
| 67 |
|
| 68 |
When switching between toolchains that use different runtime libraries, it is |
| 69 |
generally advised not to mix static libraries, unless certain exceptions apply. |
| 70 |
If in doubt, it is recommended to rebuild all static libraries when switching |
| 71 |
the toolchain's runtime DLL. |
| 72 |
|
| 73 |
Dynamic libraries are less likely to be affected. If the CRT is not part of the |
| 74 |
ABI of a library you intend to use, meaning it does not involve passing FILE |
| 75 |
structs or similar types between modules or depending on the CRT allocator of |
| 76 |
other modules, it should remain unaffected. Otherwise, a compatible build of |
| 77 |
that library will be required. |
| 78 |
|
| 79 |
|
| 80 |
== See Also == |
| 81 |
|
| 82 |
"MSVCRT vs UCRT": https://www.msys2.org/docs/environments/ |