I have Visual Studio 2017 Community edition installed on my PC. Recently I installed Qt5.10.1. I generated a VS project from one of the example .pro files:
qmake -tp vc cube.pro
However when I open this VS project and build it I get the error:
The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".
How do I specify once for all that qmake shall target Windows SDK 10.0 instead of 8.1 so that I don't have to retarget manually each time I generate a VS project with qmake?
You cannot select Windows SDK version from qmake
.
qmake
expects that the environment is correctly setup before it is run.
If you use the command line directly, you will see the following message: Remember to call vcvarsall.bat to complete environment setup!
.
This means that you have to run vcvarsall.bat
with the proper options to setup the MSVC toolchain including your selected Windows SDK version.
Some examples:
# 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
And the help message from 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
If you use Qt Creator, you are out of luck. Qt Creator just detects the installed MSVC toolchains, but does not provide any means to add options to the vcvarsall.bat
call or to manually add an MSVC toolchain.
Please read the answer of Benjamin T first. This answer elaborates on how it can be configured using QtCreator
QtCreator
allows to specify the arguments passed to vcvarsall.bat
. Go to Tools > Options > Kits > Compilers:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With