简体   繁体   English

什么提供了 C/C++ 运行时库?

[英]What provids C/C++ runtime libraries?

I have following 2 questions wrt to Windows SDK and Platform toolsets and C/C++ runtime library.我对 Windows SDK 和平台工具集和 C/C++ 运行时库有以下 2 个问题。

  • a) What is the relation of Windows SDK with C/C++ runtime and platform toolset? a) Windows SDK 与 C/C++ 运行时和平台工具集有什么关系? Is it correct to say that BOTH C++ runtime libraries & platform toolsets are provided by Windows SDK?说 C++ 运行时库和平台工具集都由 Windows SDK 提供是否正确? Since we mostly deal with Platform toolsets from within the Visual Studio project settings, so want to understand that whether under the hood does the Visual Studio controls the C++ runtime library and platform toolset versions by installing the required version of Windows SDK?由于我们主要从 Visual Studio 项目设置中处理平台工具集,因此想了解 Visual Studio 是否通过安装所需版本的 Windows ZF20E3C5E50BF8B3D37AZ5D66 来控制 C++ 运行时库和平台工具集版本?

  • b) Another thing i wanted to clarify was that if it is correct to say one version of platform toolset can work with different version of Windows SDK OR these are totally unrelated? b)我想澄清的另一件事是,如果说一个版本的平台工具集可以与不同版本的 Windows SDK 一起使用是正确的,还是这些完全不相关? eg.例如。 in my Visual Studio i see that 'Windows SDK version' is Windows 10 and Platform toolset is v142.在我的 Visual Studio 中,我看到“Windows SDK 版本”是 Windows 10,平台工具集是 v142。 Can i set the 'Windows SDK version' to Windows 8.1 and keep the toolset as v142?我可以将“Windows SDK 版本”设置为 Windows 8.1 并将工具集保持为 v142 吗? If yes, then what does it mean?如果是,那是什么意思?

This is confusing me a lot and i can't seem to get the correct picture with so many different explanations from different people.这让我很困惑,我似乎无法从不同的人那里得到如此多不同的解释。

TL;DR: If you are using Visual C++, and use the standard REDIST instructions from Microsoft Docs , then these details shouldn't really matter to you. TL;DR:如果您使用 Visual C++,并使用Microsoft Docs中的标准 REDIST 指令,那么这些细节对您来说并不重要。

With VS 2015 and later, the "C/C++ Runtime" has been refactored into three pieces:在 VS 2015 及更高版本中,“C/C++ 运行时”已被重构为三个部分:

  • UCRTBASE.DLL is part of the OS and serviced through Windows Update. UCRTBASE.DLL是操作系统的一部分,通过 Windows 更新提供服务。 There are 'down-level' versions of it included in the Visual C++ REDIST package, but generally you should think of this as the "OS" part. Visual C++ REDIST package 中包含它的“下级”版本,但通常您应该将其视为“操作系统”部分。 This is the "C Runtime".这是“C 运行时”。 These headers, import libraries, and are in the Windows 10 SDK.这些头文件、导入库和位于 Windows 10 SDK 中。 You can find the source for it there as well C:\Program Files (x86)\Windows Kits\10\Source\<version>\ucrt .您也可以在那里找到它的源代码C:\Program Files (x86)\Windows Kits\10\Source\<version>\ucrt

  • MSVCP*.DLL This is the "C++ Runtime" library, basically stuff like std::vector et al. MSVCP*.DLL这是“C++ 运行时”库,基本上像std::vector等。 The headers, import libraries, and such are in the Visual C++ product.头文件、导入库等位于 Visual C++ 产品中。 You can find the source to it on GitHub perthis blog post .根据这篇博文,您可以在GitHub上找到它的源代码。

  • VCRUNTIME*.DLL has the entry-points needed at runtime for the Visual C++ compiler language features. VCRUNTIME*.DLL具有 Visual C++ 编译器语言功能在运行时所需的入口点。

There are also a few auxiliary libraries as well for specific scenarios:还有一些针对特定场景的辅助库:

  • VCCORLIB*.DLL is used for C++/CX extensions (aka /ZW ) VCCORLIB*.DLL用于C++/CX 扩展(又名/ZW

  • VCAMP140.DLL is used for C++ AMP VCAMP140.DLL用于C++ AMP

  • VCOMP140.DLL is used for OpenMP VCOMP140.DLL用于OpenMP

  • CONCRT*.DLL is used to implement C++11 <thread> on Windows XP (not used on newer versions of Windows; it's delay loaded if required) CONCRT*.DLL is used to implement C++11 <thread> on Windows XP (not used on newer versions of Windows; it's delay loaded if required)

See this blog post and this one .请参阅这篇博客文章这篇文章。

Essentially the C runtime (the UCRTBASE) part is a simple extern "C" interface so the ABI is well-defined, and thus is usable with multiple versions of Visual C++ and even other compilers.本质上,C 运行时(UCRTBASE)部分是一个简单的extern "C"接口,因此 ABI 定义明确,因此可用于 Visual C++ 甚至其他编译器的多个版本。 Exactly which version of the UCRT you are using is therefore primarily depending on the OS and the Windows 10 SDK you are using via WindowsTargetPlatformVersion .因此,您使用的 UCRT 的确切版本主要取决于您通过WindowsTargetPlatformVersion使用的操作系统和 Windows 10 SDK。 You can applocal deploy UCRT as well per this blog .您也可以根据此博客applocal 部署 UCRT。

The C++ Runtime (MSVCP*.DLL) includes a lot of inlines and exposed memory layouts, and historically there was a breaking change between between Visual C++ versions. C++ 运行时 (MSVCP*.DLL) 包括大量内联和暴露的 memory 布局,历史上 Visual ZF6F87C9FDCF8B3C3F07F93F1EE8712C9 版本之间存在重大变化That said, for VS 2015 Update 3, VS 2017, and VS 2019 the VC team has made a point of keeping 'binary compatibly' here meaning that if you have a static library that uses C++ std namespace components from a PlatformToolset of v140/v141, it will successfully link with a later version of Visual C++ up through v142.也就是说,对于 VS 2015 Update 3、VS 2017 和 VS 2019,VC 团队在此处强调保持“二进制兼容”,这意味着如果您有一个PlatformToolset库,该库使用 C++0stv14 命名空间组件,它将成功链接到更高版本的 Visual C++ 到 v142。 It's not clear that this will hold in the future, but it is true for this particular set of releases per Microsoft Docs .目前尚不清楚这是否会在未来保持不变,但对于每个Microsoft Docs的这组特定版本来说确实如此。

The VCRUNTIME*.DLL needs to match the version of the Visual C++ compiler you are using to build the final link, so this is very much intended to match your PlatformToolset . VCRUNTIME*.DLL需要与您用于构建最终链接的 Visual C++ 编译器的版本相匹配,因此这非常适合您的PlatformToolset

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM