Differences between msvcrt, ucrt and vcruntime libraries
Asked Answered
R

1

36

Can someone please explain the difference between these? Internet lookup has confused me.

I am using VS2019.

Rabbi answered 5/6, 2021 at 11:15 Comment(0)
E
58

MSVCRT vs UCRT These are two variants of the C standard library on Microsoft Windows.

MSVCRT (Microsoft Visual C++ Runtime) is available by default on all Microsoft Windows versions, but due to backwards compatibility issues is stuck in the past, not C99 compatible and is missing some features.

  • It isn't C99 compatible, for example the printf() function family, but...
  • mingw-w64 provides replacement functions to make things C99 compatible in many cases
  • it doesn't support the UTF-8 locale
  • Binaries linked with MSVCRT should not be mixed with UCRT ones because the internal structures and data types are different. Same rule is applied for MSVC compiled binaries because MSVC uses UCRT by default (if not changed).
  • Works out of the box on every Microsoft Windows versions.

UCRT (Universal C Runtime) is a newer version which is also used by Microsoft Visual Studio by default. It should work and behave as if the code was compiled with MSVC.

  • Better compatibility with MSVC, both at build time and at run time.
  • It only ships by default on Windows 10 and for older versions you have to provide it yourself or depend on the user having it installed.

credit: https://www.msys2.org/docs/environments/

Ethelinda answered 1/8, 2021 at 11:23 Comment(2)
This is a good answer, but it doesn't explain the relationship between ucrt and vcruntime, which the question was also asking. The answer to that is, Microsoft split their CRT into two parts, one which was specific to their compilers (vcruntime), the other generic to all compliers (ucrt). So if you are using a non-Microsoft compiler (like Clang or GCC), you still use ucrt, but not vcruntime; vcruntime is only supposed to be used by Microsoft's compilers. Source: learn.microsoft.com/en-us/cpp/porting/…Euphrosyne
Some more docs: learn.microsoft.com/en-us/cpp/c-runtime-library/…Defer

© 2022 - 2024 — McMap. All rights reserved.