【问题标题】:Why windows-sdk can not be linked properly when use cl or msbuild?为什么使用 cl 或 msbuild 时 windows-sdk 无法正确链接?
【发布时间】:2019-05-08 16:02:37
【问题描述】:

我使用 VS2017 构建了一些 c++ 项目,并且成功了。当我用MSBuildcl或qt-creator用msvc工具构建一些库时,总是出现“无法打开包含文件”的错误,而这些丢失的包含文件都位于Windows Kit,例如:

e:\workspace\boost_1_70_0\tools\build\src\engine\jam.h(71): fatal error C1083: can not open include file: "ctype.h": No such file or directory
e:\workspace\boost_1_70_0\tools\build\src\engine\strings.h(11): fatal error C1083: can not open include file: "stddef.h": No such file or directory
order.c
e:\workspace\boost_1_70_0\tools\build\src\engine\modules\../mem.h(67): fatal error C1083: can not open include file: "stdlib.h": No such file or directory

找了解决办法,终于找到了qt的:当我加上下面两行,qt-creator with msvc tools就可以构建成功了:

win32 {
    INCLUDEPATH += "F:\\Windows Kits\\10\\Include\\10.0.17763.0\\ucrt\\"
    LIBS += -L"F:\\Windows Kits\\10\\Lib\\10.0.17763.0\\ucrt\\x86\\"
}

对于this,我检查了user.props

<?xml version="1.0" encoding="utf-8"?> 
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets">
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup />
  <ItemDefinitionGroup />
  <ItemGroup />
</Project>

很明显,WindowsSDKVersionWindowsSDK_IncludesPathWindowsSDK_LibraryPath 或其他有关 Windows SDK 的问题出现了问题。但是这个问题直到今年才存在。我不知道发生了什么。

有没有办法纠正WindowsSDK_IncludesPathWindowsSDK_LibraryPath,或者至少可以使用msbuild和cl?

【问题讨论】:

  • 这与SDK没有任何关系。 CRT 在 2015 年一分为二,目的是为 UWP 程序提供自己的 CRT 副本,由 Windows Update 分发。为什么您的 qt-creator 副本不知道这是不可猜测的,也许它很旧,您必须更新它。
  • 对不起,我有点困惑......但是当我使用 VS2017(GUI) 时没有任何问题。而且看来如果我想更新CRT我需要更新windows?(windows更新效果很好)

标签: visual-studio-2017


【解决方案1】:

嗯...我终于找到了一个“肮脏”的解决方案: 我编辑vcvarsall.bat,将__VCVARSALL_WINSDK的默认值更改为我的目标WindowsSDK版本: %WindowsSDKVersion%是我之前设置的环境变量)

似乎一切都很好......希望如此

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-17
    • 2013-09-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多