【问题标题】:How to build against the windows 8.1 SDK如何针对 windows 8.1 SDK 构建
【发布时间】:2015-05-05 22:18:15
【问题描述】:

我的设置如下:

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

但是,当我在 Visual Studio 中检查宏时,它现在是针对 Windows SDK 8.0 而不是 8.1 构建的。

谁能解释为什么会这样?我无法使用我的设置针对 Windows 8.1 SDK 进行构建,是否无法使用 Visual Studio 2012?我找不到任何确凿的信息来告诉我它是否受支持。

【问题讨论】:

    标签: c++ windows visual-studio winapi visual-studio-2012


    【解决方案1】:

    发生了什么

    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 进行构建

    this blog中所述:

    VS 2010/2012 用户:您可以使用最初用于 VS 2010+Windows 8.0 SDK 的 Visual C++ Team blog post 中描述的 Windows 8.1 SDK 的属性表技术。对于 VS 2010,只需将带有“8.0”/“win8”的路径部分更改为“8.1”/“winv6.3”,否则使用所有这些说明。对于 VS 2012,您可以简化所有路径,只需在每个变量的现有值之前添加 8.1 路径。更新的 .props 附在这篇博文中。这应该只用于 Win32 桌面应用程序开发。

    进行这些更改后,您应该得到一个属性表(也作为same blog 的附件提供),对于 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 构建所需的所有路径,但它不会更改仍指向 Windows 8.0 SDK 的 WindowSdkDir 和相关宏。如果您使用这些宏来定义项目属性,这可能会导致构建不一致。

    最后,请注意 Visual Studio 2013 附带 Windows 8.1 SDK,相应地,它是与默认“Visual Studio 2013 (v120)”平台工具集属性一起使用的 SDK。因此,如果可以选择升级到 VS2013,那可能会为您省去一些麻烦。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多