无法使用v141_xp工具集进行构建(无法安装v7.1A SDK)

时间:2018-08-24 21:42:37

标签: windows visual-studio sdk visual-studio-2017

使用v141工具集和Windows 10 SDK进行编译时,

VS可以很好地工作,但是当我切换到v141_xp工具集和Windows 7.0 SDK并单击Build时,VS就会中断。 重要说明:v141_xp工具集大约在半年前就可以使用。那时,我已经在这台计算机上安装了2010年至2017年的所有Visual Studio软件。然后,我决定删除所有这些软件,但2017年除外。我不知道XP工具集是否在那之后崩溃了,因为从那时起我就一直没有使用过它。

一些默认项目的输出示例:

1>------ Build started: Project: Project1, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Platforms\Win32\PlatformToolsets\v141_xp\Toolset.targets(36,5): warning MSB8003: Could not find WindowsSdkDir_71A variable from the registry.  TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(375,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry.  TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
1>Project1.cpp
1>LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
1>Done building project "Project1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

如果我取消了XP支持,安装程序会通知我将释放220MB,但是如果我选择重新安装它,则说“所需的总空间”为507KB,这可疑地很低。 另外,每当我选择安装XP支持时,都会创建C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A,但它仍然为空。

有时候,即使安装了XP支持,当我加载XP vcxproj时,此消息也会打印两次:

Project 'Project1' could not be loaded because it's missing install components. To fix this launch Visual Studio installer with the following selections:
Windows XP support for C++

安装缺少的功能无法修复它,甚至无法重新安装整个VS。

1 个答案:

答案 0 :(得分:1)

这让我难过了一阵子。我尝试过重新安装XP构建工具,修复VS安装本身等,最后通过以下方法解决了这个问题:

  1. 打开VS 2017安装程序(“工具”菜单->“获取工具和功能”)
  2. 选择“单个组件”标签
  3. 向下滚动到“编译器,构建工具和运行时”部分
  4. 选中“ Windows XP对C ++的支持”(在该部分的底部)。

神奇地使SDK可以通过以前安装的_xp工具链找到。