Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build against the windows 8.1 SDK

My setup is the following:

Windows 8.1, Microsoft Visual Studio 2012

I wish to build against the Windows 8.1 SDK. My application is c++, no windows runtime components or anything like that.

I have the windows 8.1 SDK installed but Visual Studio is building against the Windows 7 SDK, so to switch targets I modify my registry keys which point to the current SDK version:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows Registry

However when I check the macros in Visual Studio it is now building against windows SDK 8.0 instead of 8.1.

Visual Studio Macros

Can anyone explain why this is happening? I have not been able to build against the windows 8.1 SDK with my setup, is it just not possible using Visual Studio 2012? I cannot find any conclusive information to tell me if it is supported or not.

like image 672
PAK-9 Avatar asked Mar 04 '15 19:03

PAK-9


1 Answers

What's going on

The WindowsSdkDir is a Visual Studio internal variable which is derived from registry keys based on the "Platform Toolset" project property (under "Configuration Properties / General"). For the "Visual Studio 2012 (v110)" platform toolset, registry keys such as:

HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0
HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0
HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.0
HKCU\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.0

are used, irrespective of the CurrentVersion and CurrentInstallFolder keys.

How to build against Windows 8.1 SDK with Visual Studio 2012

As to described in this blog:

VS 2010/2012 users: You can use the property sheet technique for the Windows 8.1 SDK that was described in this Visual C++ Team blog post originally for VS 2010+Windows 8.0 SDK. For VS 2010, just change the part of the paths with "8.0"/"win8" to "8.1"/"winv6.3" but otherwise use all those instructions. For VS 2012, you can simplify all the paths to just add the 8.1 paths before the existing value for each variable. The updated .props are attached to this blog post. This should only be used for Win32 desktop application development.

After making those changes, you should get a property sheet (which is also provided as an attachment to the same blog) which for x86 looks like:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <ExecutablePath>$(ProgramFiles)\Windows Kits\8.1\bin\x86;$(ExecutablePath)</ExecutablePath>
    <IncludePath>$(ProgramFiles)\Windows Kits\8.1\Include\um;$(ProgramFiles)\Windows Kits\8.1\Include\shared;$(ProgramFiles)\Windows Kits\8.1\Include\winrt;$(IncludePath)</IncludePath>
    <LibraryPath>$(ProgramFiles)\Windows Kits\8.1\lib\winv6.3\um\x86;$(LibraryPath)</LibraryPath>
    <ExcludePath>$(ProgramFiles)\Windows Kits\8.1\Include\um;$(ProgramFiles)\Windows Kits\8.1\Include\shared;$(ProgramFiles)\Windows Kits\8.1\Include\winrt;$(ExcludePath)</ExcludePath>
  </PropertyGroup>
<ItemDefinitionGroup />
</Project>

And similarly for x64:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <ExecutablePath>$(ProgramFiles)\Windows Kits\8.1\bin\x64;$(ExecutablePath)</ExecutablePath>
    <IncludePath>$(ProgramFiles)\Windows Kits\8.1\Include\um;$(ProgramFiles)\Windows Kits\8.1\Include\shared;$(ProgramFiles)\Windows Kits\8.1\Include\winrt;$(IncludePath)</IncludePath>
    <LibraryPath>$(ProgramFiles)\Windows Kits\8.1\lib\winv6.3\um\x64;$(LibraryPath)</LibraryPath>
    <ExcludePath>$(ProgramFiles)\Windows Kits\8.1\Include\um;$(ProgramFiles)\Windows Kits\8.1\Include\shared;$(ProgramFiles)\Windows Kits\8.1\Include\winrt;$(ExcludePath)</ExcludePath>
  </PropertyGroup>
<ItemDefinitionGroup />
</Project>

A word of caution however. While this would define all the paths required to build against Windows 8.1 SDK, it does not change the WindowSdkDir and related macros which would still point to the Windows 8.0 SDK. This could potentially lead to build inconsistencies if you use those macros to define project properties.

Finally, note that Visual Studio 2013 ships with Windows 8.1 SDK, and correspondingly it is the SDK used with the default "Visual Studio 2013 (v120)" platform toolset property. So if upgrading to VS2013 is an option, that might save you a bit of trouble.

like image 78
SleuthEye Avatar answered Oct 07 '22 01:10

SleuthEye