vs2012 工具集兼容性 [英] vs2012 toolset compatibility

查看:44
本文介绍了vs2012 工具集兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 VS2012 中,我有 4 个可用的工具集:v90、v100、v110 和 v110_xp.我用两个项目 testlib(一个静态库)和 testexe(控制台应用程序)做了一个简单的测试.接口只是一个带有 void test() 签名的函数.结果:

In my VS2012 I have 4 toolsets available: v90, v100, v110 and v110_xp. I did a simple test with two projects testlib (a static library) and testexe (console application). The interface was just one function with signature void test(). The results:

  • testlib(v90)、testexe(v90 以外的任何东西) -> 不链接
  • testlib(v100)、testexe(v110 或 v110_xp) -> 链接

然而,我觉得 v100 和 v110 会链接起来有点奇怪,所以我试图让场景复杂化一点.现在我的方法看起来像这样: std::map测试(const std::string& arg).正如预期的那样,testlib(v100) 和 testexe(v110) 没有链接(检测到_MSC_VER"不匹配).

However, it seemed somewhat weird to me that v100 and v110 would link so I tried to complicate the scenario a little bit. Now my method looks like this: std::map<std::string, std::string> test(const std::string& arg). As expected, the testlib(v100) and testexe(v110) do not link (mismatch detected for '_MSC_VER').

但是 testlib(v110) 和 testexe(v110_xp) 仍然可以链接并且生成的 exe 可以在 Windows XP 上运行.这是偶然的还是受支持的情况?如果这只是偶然,那么欢迎使用仅使用 v110_xp 中可用的功能并破坏此兼容性的示例代码.我想知道是否应该将我的库的两个版本部署到我的客户端,或者只使用 v110 编译的一个版本就可以.

But still the testlib(v110) and testexe(v110_xp) do link and the resulting exe works on Windows XP. Is this just by chance or is this a supported scenario? If this is just by chance then an example code that is using only features available in v110_xp and breaks this compatibility would be welcome. I am wondering whether I should deploy two versions of my library to my clients or just the one compiled with v110 will do.

推荐答案

用工具集"这个词来描述 v110 和 v110_xp 之间的差异有点用词不当.您仍在使用相同的构建工具.而且您仍然拥有相同版本的 CRT.通过比较在两个版本之间加载的 DLL 的 Debug + Windows + Module 列表中看到的内容,您可以看到一些内容.记下 msvcr110.dll 的名称和位置.

The word "toolset" is a bit of a misnomer to describe the differences between v110 and v110_xp. You are still using the same build tools. And you still have the same version of the CRT. Something you can see by comparing what you see in the Debug + Windows + Module list of loaded DLL between the two builds. Note the name and location of msvcr110.dll.

CRT 实际上是由 Update 1 更新的,它现在支持 XP 和更新的 Windows 版本.这是通过它在运行时动态绑定到后来的 winapi 函数来实现的,使用 GetProcAddress(),如果在 XP 上运行时找不到它们,则一瘸一拐地走.

The CRT was in fact updated by Update 1, it now supports both XP and newer Windows versions. This works by it binding dynamically to the later winapi functions at runtime, using GetProcAddress(), limping along if it can't find them when you run on XP.

不同的是,您获得了另一个版本的 Windows SDK.最后一个仍然与 XP 版本 7.1 兼容.您会在 C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A 中找到它.当您使用 v110 工具集进行构建时,您将使用存储在 C:\Program Files (x86)\Windows Kits\8.0 中的 SDK 包含和库文件

What is different is that you got another version of the Windows SDK. The last one that was still compatible with XP, version 7.1. You'll find it back in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A. When you build with the v110 toolset then you'll use the SDK include and library files stored in C:\Program Files (x86)\Windows Kits\8.0

在 c:\program files (x86)\msbuild 目录中搜索该字符串时,可以看到使用 v110_xp 时的特定更改:

The specific changes when you use v110_xp are visible when you search the c:\program files (x86)\msbuild directory for that string:

  • 包含和 lib 文件等的目录已更改为 Windows 7.1 SDK 路径
  • 添加了 _USING_V110_SDK71_ 预处理器符号,否则不会在任何重要的地方使用
  • 链接器的/SUBSYSTEM 选项已更改为仅需要 Windows 版本 5.02,即 XP 版本号.

长话短说,混合使用 v110 和 v110_xp 工具集构建的模块不是问题.

Long story short, mixing modules that were built with a mix of v110 and v110_xp toolsets is not a problem.

这篇关于vs2012 工具集兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆