缺少 SDKDDKVer.h,但安装了 WinSDK?(C++ 头文件问题)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22390539/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 00:03:53  来源:igfitidea点击:

SDKDDKVer.h missing, but WinSDK installed? (c++ header issues)

c++visual-c++visual-studio-2012header

提问by Ary-Senpai

So I recently returned to VC++ with .NET 4.5 (Visual Studio 2012 professional) due to various irrelevant reasons on a new PC after spending an eternity with web dev, python and c#. I'm pretty comfortable with the language as a whole, it's f**king beautiful in terms of syntax and I love the memory management freedom, pointers and references. I start up again with a "hello world" thing and BAM! Error.

因此,在与 Web 开发、python 和 c# 一起度过了永恒之后,由于各种不相关的原因,我最近使用 .NET 4.5(Visual Studio 2012 专业版)回到了 VC++。我对整个语言非常满意,它在语法方面非常漂亮,我喜欢内存管理自由、指针和引用。我用“你好世界”的东西和 BAM 重新开始!错误。

As many other people get with this problem, I'm receiving the IntelliSense error when I try to compile and run:

正如许多其他人遇到这个问题一样,当我尝试编译和运行时,我收到了 IntelliSense 错误:

cannot open source file "SDKDDKVer.h"" and the fatal error: "error C1083: Cannot open include file: 'SDKDDKVer.h': No such file or directory

cannot open source file "SDKDDKVer.h"" and the fatal error: "error C1083: Cannot open include file: 'SDKDDKVer.h': No such file or directory

I also have Visual Studio 2010 (C# Express) installed, perhaps that's screwing up some of my stuff. I've confirmed that my VC++ directories for incl and lib are all correct and that recommended by Microsoft and virtually any C++ developer. I attempted to install the most recent WinSDK (8.1) to get the header and all of it's functionality but I'm about 110% certain it's not in there. I'm installing the SDK for Win7 right now in hopes that it might reside in there (it's sure taking a long time though.)

我还安装了 Visual Studio 2010 (C# Express),也许这搞砸了我的一些东西。我已经确认我的 VC++ 目录 incl 和 lib 都是正确的,并且是 Microsoft 和几乎所有 C++ 开发人员推荐的。我试图安装最新的 WinSDK (8.1) 来获取标头及其所有功能,但我大约 110% 确定它不在那里。我现在正在为 Win7 安装 SDK,希望它可以驻留在那里(虽然肯定需要很长时间。)

My PC has the issue of terminally blue-screening only for any issue to be resolved upon leaving the machine alone for 15 minutes, so maybe it's a hard-drive issue?

我的电脑有终端蓝屏的问题,只有在将机器单独放置 15 分钟后才能解决任何问题,所以这可能是硬盘驱动器问题?

Can any of you help? Absolutely any heads up, condescending, obvious or not will be appreciated a ton, and thanks for reading anyway.

你们中的任何人都可以帮忙吗?绝对任何抬头,居高临下,明显与否,都会受到极大的赞赏,无论如何,感谢您的阅读。

EDIT: @MichaelBurr asked for the build log and I couldn't post it in its entirety at the bottom, so I figured I'd add it here.

编辑:@MichaelBurr 要求提供构建日志,但我无法在底部完整地发布它,所以我想我会在这里添加它。

Build started 14/03/2014 00:34:11.
 1>Project "c:\Users\Brandon\documents\visual studio 2012\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.vcxproj" on node 2 (Build target(s)).
 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppBuild.targets(344,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry.  TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
 1>ClCompile:
     C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Yc"stdafx.h" /Fp"Debug\ConsoleApplication4.pch" /Fo"Debug\" /Fd"Debug\vc110.pdb" /Gd /TP /analyze- /errorReport:prompt stdafx.cpp
     stdafx.cpp
 1>c:\users\brandon\documents\visual studio 2012\projects\consoleapplication4\consoleapplication4\targetver.h(8): fatal error C1083: Cannot open include file: 'SDKDDKVer.h': No such file or directory
 1>Done Building Project "c:\Users\Brandon\documents\visual studio 2012\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.vcxproj" (Build target(s)) -- FAILED.

Build FAILED.

构建失败。

Time Elapsed 00:00:00.12

已用时间 00:00:00.12

采纳答案by JohnCz

Do you have the same problem the blank project you posted? I have tried and built your project using Windows 7 32 and 64 bit and XP 32 bit. All builds fine, no problem with finding SDKDDKVer.h.

您发布的空白项目是否有同样的问题?我已经尝试使用 Windows 7 32 位和 64 位以及 XP 32 位构建您的项目。一切都很好,找到 SDKDDKVer.h 没有问题。

You must have some problem with your dependencies path settings.

您的依赖项路径设置一定有问题。

It is possible that you have transferred VS settings from one installation of VS to another, possibly from 32-bit to 64-bit (or vice versa) machine? If this is a case, remember that your path may include wrong folders names. For 32-bit system all applications are installed as default to C:\Program Files, while on 64-bit machine all 32bit apps are installed to Program Files (x86). This is a case for VS. All include files are in:

您可能已经将 VS 设置从一个 VS 安装转移到另一个,可能是从 32 位到 64 位(反之亦然)机器?如果是这种情况,请记住您的路径可能包含错误的文件夹名称。对于 32 位系统,所有应用程序默认安装到 C:\Program Files,而在 64 位机器上,所有 32 位应用程序都安装到 Program Files (x86)。这是 VS 的情况。所有包含文件都在:

  • C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include - original VS installation
  • C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include - after installing 7.1 VS SDK
  • C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include - 原始 VS 安装
  • C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include - 安装 7.1 VS SDK 后

If you have other SDK packages installed you may have another folders with SDKDDKVer.h:

如果您安装了其他 SDK 包,您可能有另一个包含 SDKDDKVer.h 的文件夹:

  • C:\Program Files (x86)\Windows Kits\8.0\Include\shared
  • C:\Program Files (x86)\Windows Kits\8.1\Include\shared
  • C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include
  • C:\Program Files\Microsoft SDKs\Windows\v7.0\Include
  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Include
  • C:\Program Files (x86)\Windows Kits\8.0\Include\shared
  • C:\Program Files (x86)\Windows Kits\8.1\Include\shared
  • C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include
  • C:\Program Files\Microsoft SDKs\Windows\v7.0\Include
  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Include

In your project setting you should have the following paths for includes:

在您的项目设置中,您应该具有以下包含路径:

  • $(VCInstallDir)include
  • $(VCInstallDir)atlmfc\include
  • $(WindowsSDK_IncludePath)
  • $(VCInstallDir)包括
  • $(VCInstallDir)atlmfc\include
  • $(WindowsSDK_IncludePath)

Note macros used. They should be inherited from parent's default setrtings. You may have overridden path settings in Property manager, by editing setting saved in Microsoft.Cpp.Win32.user.props file.

注意使用的宏。它们应该从父级的默认设置继承。您可能通过编辑保存在 Microsoft.Cpp.Win32.user.props 文件中的设置覆盖了属性管理器中的路径设置。

It may have happened if your project is converted from earlier versions of VS.

如果您的项目是从 VS 的早期版本转换而来的,则可能会发生这种情况。

回答by Mustafa Kemal

If above information couldn't solve your problem, I am proposing below steps from my VS2013 experiences:

如果以上信息不能解决您的问题,我根据我的 VS2013 经验提出以下步骤:

  1. Select Project Properties>Configuration>VC++ Directories>Include Directoriesand add that: c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
  2. Select Project Properties>Configuration>VC++ Directories>Library Directoriesand add that: c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib
  1. 选择 Project Properties>Configuration>VC++ Directories> Include Directories并添加:c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
  2. 选择项目属性>配置>VC++目录>库目录并添加:c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib

After that configuration I had problem about rc.exe link error. For this problem one more thing is needed:

在该配置之后,我遇到了关于 rc.exe 链接错误的问题。对于这个问题,还需要做一件事:

  1. copy RC.exeand RcDll.dllfiles from C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Binand past them to C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\binAfter all those configuration steps, you can build a simple "Hello World!" example and run if you are lucky.
  1. RC.exeRcDll.dll文件从C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin 复制C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin完成所有这些配置步骤后,您可以构建一个简单的“Hello World!” 示例并运行,如果你幸运的话。

回答by Daniel Khalaieff

This one worked for me: "recently had this problem when I converted a solution from VS2010 to VS2013. I solved it by simply checking the "Inherit from parent or project defaults" check box under Project Properties>Configuration>VC++ Directories>Include Directories for all configurations of each project."

这个对我有用:“最近在我将解决方案从 VS2010 转换为 VS2013 时遇到了这个问题。我通过简单地选中项目属性>配置>VC++ 目录>包含目录下的“从父级或项目默认值继承”复选框解决了这个问题每个项目的所有配置。”

回答by Bjerner

I just had this exact problem. After hours and hours in trying to find the problem by looking at different paths and trying to change them, uninstalling all MS products and reinstalling them etc. without any success, I found the solution to be to open the file C:\Users\{user}\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props and changing

我刚刚遇到了这个确切的问题。通过查看不同的路径并尝试更改它们,卸载所有 MS 产品并重新安装它们等,数小时后试图找到问题,但没有任何成功,我发现解决方案是打开文件 C:\Users\{ user}\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props 和更改

<PropertyGroup>
  <IncludePath>$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;C:\Program Files (x86)\BCGSoft\BCGControlBarPro\BCGCBPro;C:\Program Files (x86)\BCGSoft\BCGControlBarPro\BCGCBPro</IncludePath>
  <LibraryPath>$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;C:\Program Files (x86)\BCGSoft\BCGControlBarPro\bin;C:\Program Files (x86)\BCGSoft\BCGControlBarPro\bin</LibraryPath>
</PropertyGroup>

to

<PropertyGroup />

I don't know how this problem arose, but I found the solution by copying the file from my colleague's machine where it all worked fine. The problem might be caused to recent install and uninstall of BCGControlBarPro...

我不知道这个问题是如何产生的,但我通过从我同事的机器上复制文件找到了解决方案,在那里一切正常。问题可能是由于最近安装和卸载 BCGControlBarPro...

回答by Elnaz Yousefi

The Mustafa Kemal's answer is correct but if you don't want to add this directory and library for each VC++ project seperately, you should define them as system variables in Environment Variables of Windows and then restart computer.

Mustafa Kemal 的回答是正确的,但是如果您不想为每个 VC++ 项目单独添加此目录和库,则应在 Windows 的环境变量中将它们定义为系统变量,然后重新启动计算机。

Variable Name: WindowsSDK_IncludePath, Variable Value: c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include.

变量名称:WindowsSDK_IncludePath,变量值:c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include。

and

Variable Name: WindowsSDK_LibraryPath_x86, Variable Value: c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib

变量名称:WindowsSDK_LibraryPath_x86,变量值:c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib

回答by Kenny Blackmon

I know that there are several answers here to this question, but I wanted to explain what solved the issue for me. I searched and searched and searched and didn't find much good material. The solution for me was to right click on my project, the go to properties. In the properties tab, I changed the WindowsSDK Version to the only one that I had installed. That fixed the issue.

我知道这个问题有几个答案,但我想解释是什么为我解决了这个问题。我搜索了又搜索了又搜索,并没有找到太多好的材料。我的解决方案是右键单击我的项目,转到属性。在属性选项卡中,我将 WindowsSDK 版本更改为我唯一安装的版本。这解决了问题。

Why did this occur? I am not sure, but it happened after Visual Studio performed an update and after Windows Update installed the newest build of Windows 10. My guess is that when this happened, the SDK version in the project did not match the SDK installed.

为什么会出现这种情况?我不确定,但它发生在 Visual Studio 执行更新和 Windows Update 安装最新版本的 Windows 10 之后。我的猜测是,当发生这种情况时,项目中的 SDK 版本与安装的 SDK 不匹配。

I hope this saves someone in the future hours of searching!

我希望这可以在以后的搜索中拯救某人!

回答by Shane

I recently had this problem when I converted a solution from VS2010 to VS2013. I solved it by simply checking the "Inherit from parent or project defaults" check box under Project Properties>Configuration>VC++ Directories>Include Directoriesfor all configurations of each project.

我最近在将解决方案从 VS2010 转换为 VS2013 时遇到了这个问题。我通过简单地选中项目属性>配置>VC++目录>包含每个项目的所有配置的目录下的“从父级或项目默认值继承”复选框来解决它。

回答by JohnCz

I am running 2008, 2010, 1012 and 2013 installed on the same machine - Windows 7 and XP 32 and 64-bit, 7 32-bit, without any problem.

我在同一台机器上运行 2008、2010、1012 和 2013 - Windows 7 和 XP 32 和 64 位、7 32 位,没有任何问题。

Are you trying to build a project created by another version of VS?

您是否正在尝试构建由另一个版本的 VS 创建的项目?

It looks like you have a problem with dependencies set in your project or you have a problem with SDK version that is set to the wrong version.

看起来您的项目中设置的依赖项有问题,或者您的 SDK 版本设置为错误版本。

If you create another project, for example, dialog based application; does this problem persist? You do not have to run any batch file.

如果您创建另一个项目,例如基于对话框的应用程序;这个问题还存在吗?您不必运行任何批处理文件。

  • Open project properties (right click on the project and select properties).

  • Select General under Configuration Properties

  • Check the Platform Toolset on in the right pane. It should not be set to Visual Studio 2008 (V90).

  • 打开项目属性(右键单击项目并选择属性)。

  • 在配置属性下选择常规

  • 检查右窗格中的平台工具集。它不应设置为 Visual Studio 2008 (V90)。

Try rebuilding. If problem persists, share your project.

尝试重建。如果问题仍然存在,请分享您的项目。

Zip it and use some of the share services to post it (dropbox for example).

压缩它并使用一些共享服务来发布它(例如 Dropbox)。

回答by shaima alsalihy

This sometimes happens when you add a path for your include or library and delete the original ones that are already written in the project properties.

当您为包含或库添加路径并删除已写入项目属性中的原始路径时,有时会发生这种情况。

You should not remove the old path for include or lib directories, such as $(VCInstallDir)include; $(VCInstallDir)altmfc\include; $(WindowsSdkDir)include; $(FrameworkSDKDir)\include;

您不应删除包含或 lib 目录的旧路径,例如 $(VCInstallDir)include;$(VCInstallDir)altmfc\include; $(WindowsSdkDir)包括;$(FrameworkSDKDir)\include;

The same thing is for lib path just replace each include by lib.

同样的事情是 lib 路径只需用 lib 替换每个包含。

Best Regards

此致