Windows Can';使用v141èu xp工具集构建(可以安装v7.1A SDK)

Windows Can';使用v141èu xp工具集构建(可以安装v7.1A SDK),windows,visual-studio,sdk,visual-studio-2017,Windows,Visual Studio,Sdk,Visual Studio 2017,VS在使用v141工具集和Windows 10 SDK进行编译时工作正常,但当我切换到v141\u xp工具集和Windows 7.0 SDK并点击Build时,它就会中断。 重要提示:v141_xp大约半年前使用的工具集。当时,我已经在这台机器上安装了从2010年到2017年的所有Visual Studio软件。然后我决定删除所有这些,除了2017年。我不知道XP工具集是否在那之后坏了,因为从那以后我就没用过它 某些默认项目的输出示例: 1>------ Build started: P

VS在使用
v141
工具集和Windows 10 SDK进行编译时工作正常,但当我切换到
v141\u xp
工具集和Windows 7.0 SDK并点击Build时,它就会中断。 重要提示:
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 SDK\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。

这让我有一段时间感到困惑。我曾尝试重新安装XP构建工具,修复VS安装本身,等等。我最终通过以下方式解决了这一问题:

  • 打开VS 2017安装程序(工具菜单->获取工具和功能)
  • 选择“单个组件”选项卡
  • 向下滚动到“编译器、构建工具和运行时”部分
  • 检查“Windows XP对C++的支持”(在该部分的底部)
  • 这神奇地使SDK可以通过之前安装的xp工具链找到