如何使用Windows 8.1 SDK进行构建

7

我的环境如下:

Windows 8.1, Microsoft Visual Studio 2012

我希望使用Windows 8.1 SDK进行构建,我的应用程序是c++,没有使用Windows运行时组件或其他类似的东西。

我已经安装了Windows 8.1 SDK,但是Visual Studio正在使用Windows 7 SDK进行构建,因此为了切换目标,我修改了指向当前SDK版本的注册表键:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows Registry

然而,当我检查Visual Studio中的宏时,它现在正在使用8.0而不是8.1版本的Windows SDK进行构建。

Visual Studio Macros

有人能解释一下这是为什么吗?我无法在我的设置中使用Windows 8.1 SDK进行构建,这是因为使用Visual Studio 2012不支持吗?我找不到任何确凿的信息告诉我是否支持。

1个回答

7

发生了什么事

WindowsSdkDir 是一个 Visual Studio 内部变量,它基于“平台工具集”项目属性(在“配置属性 / 一般”下)的注册表键派生而来。对于“Visual Studio 2012 (v110)”平台工具集,注册表键如下:

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

无论 CurrentVersionCurrentInstallFolder 键如何,都会被使用。

如何在 Visual Studio 2012 中使用 Windows 8.1 SDK

如此描述在这篇博客中

VS 2010/2012 用户: 您可以使用属性表技术为 Windows 8.1 SDK 创建项目,这在这个Visual C++ Team 博客文章中为 VS 2010+Windows 8.0 SDK 原始提出。对于 VS 2010,只需将路径部分的 "8.0"/"win8" 更改为 "8.1"/"winv6.3" ,然后使用所有这些说明。对于 VS 2012,您可以简化所有路径,只需在每个变量的现有值之前添加 8.1 路径即可。更新的 .props 文件附在本博客中。这仅适用于 Win32 桌面应用程序开发。

进行这些更改后,对于 x86,您应该可以获得一个属性表(也作为同一篇博客的附件):

<?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>

同样适用于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>

请注意,这里有一个警告。尽管这将定义构建对Windows 8.1 SDK所需的所有路径,但它不会更改WindowSdkDir和相关宏,这些宏仍然指向Windows 8.0 SDK。如果您使用这些宏来定义项目属性,可能会导致构建不一致。
最后,请注意Visual Studio 2013附带Windows 8.1 SDK,并相应地是默认的“Visual Studio 2013(v120)”平台工具集属性所使用的SDK。因此,如果升级到VS2013是一个选择,那么可能会为您节省一些麻烦。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接