如何指定 qmake 应针对哪个 Windows SDK 版本?
How do I specify which Windows SDK version qmake shall target?
我的电脑上安装了 Visual Studio 2017 社区版。
最近我安装了Qt5.10.1。
我从示例 .pro 文件之一生成了一个 VS 项目:
qmake -tp vc cube.pro
然而,当我打开这个 VS 项目并构建它时,出现错误:
未找到 Windows SDK 版本 8.1。安装所需版本的 Windows SDK 或在项目 属性 页面中更改 SDK 版本,或者右键单击解决方案并选择 "Retarget solution"。
我如何一次指定 qmake 应以 Windows SDK 10.0 而不是 8.1 为目标,这样我就不必每次使用 qmake 生成 VS 项目时都手动重新定位?
您不能 select Windows 来自 qmake
的 SDK 版本。
qmake
期望在 运行 之前正确设置环境。
如果直接使用命令行,您将看到以下消息:Remember to call vcvarsall.bat to complete environment setup!
。
这意味着您必须 运行 vcvarsall.bat
使用正确的选项来设置 MSVC 工具链,包括您的 selected Windows SDK 版本.
一些例子:
# MSVC 2017 for 64 bit
vcvarsall.bat amd64
# MSVC 2017 for 64 bit using Windows 8.1 SDK
vcvarsall.bat amd64 8.1
# MSVC 2017 for 64 bit using Windows 10 SDK version 10.0.10240.0
vcvarsall.bat amd64 10.0.10240.0
# MSVC 2015 (installed with 2017 installer) for 64 bit using Windows 10 SDK version 10.0.10240.0
vcvarsall.bat amd64 10.0.10240.0 -vcvars_ver=14.0
以及来自vcvarsall.bat
的帮助信息:
Syntax:
vcvarsall.bat [arch] [platform_type] [winsdk_version] [-vcvars_ver=vc_version]
where :
[arch]: x86 | amd64 | x86_amd64 | x86_arm | x86_arm64 | amd64_x86 | amd64_arm | amd64_arm64
[platform_type]: {empty} | store | uwp
[winsdk_version] : full Windows 10 SDK number (e.g. 10.0.10240.0) or "8.1" to use the Windows 8.1 SDK.
[vc_version] : {none} for default VS 2017 VC++ compiler toolset |
"14.0" for VC++ 2015 Compiler Toolset |
"14.1x" for the latest 14.1x.yyyyy toolset installed (e.g. "14.11") |
"14.1x.yyyyy" for a specific full version number (e.g. 14.11.25503)
The store parameter sets environment variables to support Universal Windows Platform application
development and is an alias for 'uwp'.
For example:
vcvarsall.bat x86_amd64
vcvarsall.bat x86_amd64 10.0.10240.0
vcvarsall.bat x86_arm uwp 10.0.10240.0
vcvarsall.bat x86_arm onecore 10.0.10240.0 -vcvars_ver=14.0
vcvarsall.bat x64 8.1
vcvarsall.bat x64 store 8.1
如果你用的是Qt Creator,那你就倒霉了。 Qt Creator 仅检测已安装的 MSVC 工具链,但不提供任何方法来向 vcvarsall.bat
调用添加选项或手动添加 MSVC 工具链。
请先阅读Benjamin T的回答。这个答案详细说明了如何使用 QtCreator
配置它
QtCreator
允许指定传递给 vcvarsall.bat
的参数。转到工具 > 选项 > 套件 > 编译器:
- 克隆所需的自动检测编译器
- 在Initialization的最后一栏填写需要的WindowsSDK版本:
- 可选:更新名称以便在下一步中轻松找到它
- 在 Kits > Kits 下,将编译器更改为您新创建的编译器(用于所需的 Kits)。
我的电脑上安装了 Visual Studio 2017 社区版。 最近我安装了Qt5.10.1。 我从示例 .pro 文件之一生成了一个 VS 项目:
qmake -tp vc cube.pro
然而,当我打开这个 VS 项目并构建它时,出现错误:
未找到 Windows SDK 版本 8.1。安装所需版本的 Windows SDK 或在项目 属性 页面中更改 SDK 版本,或者右键单击解决方案并选择 "Retarget solution"。
我如何一次指定 qmake 应以 Windows SDK 10.0 而不是 8.1 为目标,这样我就不必每次使用 qmake 生成 VS 项目时都手动重新定位?
您不能 select Windows 来自 qmake
的 SDK 版本。
qmake
期望在 运行 之前正确设置环境。
如果直接使用命令行,您将看到以下消息:Remember to call vcvarsall.bat to complete environment setup!
。
这意味着您必须 运行 vcvarsall.bat
使用正确的选项来设置 MSVC 工具链,包括您的 selected Windows SDK 版本.
一些例子:
# MSVC 2017 for 64 bit
vcvarsall.bat amd64
# MSVC 2017 for 64 bit using Windows 8.1 SDK
vcvarsall.bat amd64 8.1
# MSVC 2017 for 64 bit using Windows 10 SDK version 10.0.10240.0
vcvarsall.bat amd64 10.0.10240.0
# MSVC 2015 (installed with 2017 installer) for 64 bit using Windows 10 SDK version 10.0.10240.0
vcvarsall.bat amd64 10.0.10240.0 -vcvars_ver=14.0
以及来自vcvarsall.bat
的帮助信息:
Syntax:
vcvarsall.bat [arch] [platform_type] [winsdk_version] [-vcvars_ver=vc_version]
where :
[arch]: x86 | amd64 | x86_amd64 | x86_arm | x86_arm64 | amd64_x86 | amd64_arm | amd64_arm64
[platform_type]: {empty} | store | uwp
[winsdk_version] : full Windows 10 SDK number (e.g. 10.0.10240.0) or "8.1" to use the Windows 8.1 SDK.
[vc_version] : {none} for default VS 2017 VC++ compiler toolset |
"14.0" for VC++ 2015 Compiler Toolset |
"14.1x" for the latest 14.1x.yyyyy toolset installed (e.g. "14.11") |
"14.1x.yyyyy" for a specific full version number (e.g. 14.11.25503)
The store parameter sets environment variables to support Universal Windows Platform application
development and is an alias for 'uwp'.
For example:
vcvarsall.bat x86_amd64
vcvarsall.bat x86_amd64 10.0.10240.0
vcvarsall.bat x86_arm uwp 10.0.10240.0
vcvarsall.bat x86_arm onecore 10.0.10240.0 -vcvars_ver=14.0
vcvarsall.bat x64 8.1
vcvarsall.bat x64 store 8.1
如果你用的是Qt Creator,那你就倒霉了。 Qt Creator 仅检测已安装的 MSVC 工具链,但不提供任何方法来向 vcvarsall.bat
调用添加选项或手动添加 MSVC 工具链。
请先阅读Benjamin T的回答。这个答案详细说明了如何使用 QtCreator
QtCreator
允许指定传递给 vcvarsall.bat
的参数。转到工具 > 选项 > 套件 > 编译器:
- 克隆所需的自动检测编译器
- 在Initialization的最后一栏填写需要的WindowsSDK版本:
- 可选:更新名称以便在下一步中轻松找到它
- 在 Kits > Kits 下,将编译器更改为您新创建的编译器(用于所需的 Kits)。