无法在 Visual Studio C++ 项目中更改 Windows SDK 版本 [英] Can't change Windows SDK version in Visual Studio C++ project

查看:32
本文介绍了无法在 Visual Studio C++ 项目中更改 Windows SDK 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Visual Studio 2015 创建的 Visual Studio C++ 控制台应用程序,但现在我无法编译它(使用 Visual Studio 2017),因为它针对的是未安装的 Windows 8.1 SDK.问题是我无法将项目重新定位到 Windows 10 SDK.

I have a Visual Studio C++ console application that I created with Visual Studio 2015 and now I can't compile it (with Visual Studio 2017) because it is targeting the Windows 8.1 SDK, which is not installed. The problem is that I can't retarget the project to the Windows 10 SDK.

发生的情况是,当我打开项目属性页面并转到 General - Target Platform 时,我在下拉列表中看到了 Windows 10 SDK,并且我可以选择它...但是作为一旦我按下 Apply它会自行恢复到 8.1.没有提供错误消息.

What happens is that when I open the project properties page and go to General - Target Platform I see the Windows 10 SDK in the dropdown, and I am able to select it... but as soon as I press Apply, it reverts back to 8.1 by itself. No error message is provided.

Visual Studio 安装程序说,确实安装了列出的 SDK 版本:

Visual Studio installer says that, indeed, the listed SDK version is installed:

那么这里发生了什么?有没有办法重新定位我的项目而无需安装 Windows 8.1 SDK?

So what's going on here? Is there a way to retarget my project without having to install the Windows 8.1 SDK?

不确定这是否重要,但是:这个项目实际上只是一个现有裸项目的包装器",其中包含一堆 .cpp 和 .h 文件,这些文件是由另一个人开发的.我真的不熟悉 C++ 开发.

推荐答案

在解决这个问题几个小时后,我偶然发现选择Project Properties/General,将Platform Toolset"更改为v141_xp(而不是 v141) 强制将 Windows SDK 版本降至 8.1 或 7.0.我不确定 Visual Studio 如何选择使用哪个 SDK.

After hours of struggling with this problem, I coincidentally discovered that selecting Project Properties/General, changing "Platform Toolset" to v141_xp (instead of v141) forcibly drops the Windows SDK Version to 8.1 or 7.0. I'm not sure how Visual Studio chooses which SDK to use.

您必须编辑 .vcxproj 并同时更改:

You must edit .vcxproj and change both:

<TargetPlatformVersion>10.0.17134.0</TargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>

这篇关于无法在 Visual Studio C++ 项目中更改 Windows SDK 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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