C++ 未找到 Windows SDK 注册表变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22188919/
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
Windows SDK registry variable not found
提问by clashoftornados
I cannot build my project in Visual Studio 2012. The error is:
我无法在 Visual Studio 2012 中构建我的项目。错误是:
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>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppBuild.targets(344,5):警告 MSB8003:无法从注册表中找到 WindowsSDKDir 变量。TargetFrameworkVersion 或 PlatformToolset 可能设置为无效的版本号。”
I have installed Windows SDK, and have tried to reinstall and to repair, and have even tried to enter the registry string key "WindowsSDKDir" to the registry. (HKLM/SOFTWARE/Wow6432Node/Microsoft/Microsoft SDKs/v7.1 with value C:\Program Files\Microsoft SDKs\Windows\v7.1).`
我已经安装了 Windows SDK,并尝试重新安装和修复,甚至尝试将注册表字符串键“WindowsSDKDir”输入到注册表中。(HKLM/SOFTWARE/Wow6432Node/Microsoft/Microsoft SDKs/v7.1,值为 C:\Program Files\Microsoft SDKs\Windows\v7.1)。`
Is it a registry issue, or something else? I've tried searching for those registry keys and re-installing my Windows SDK but neither helped.
是注册表问题还是别的什么?我已经尝试搜索这些注册表项并重新安装我的 Windows SDK,但都没有帮助。
回答by user1274820
I was trying to get a script to compile for Script Hook V - GTA .NET Library.
我试图获得一个脚本来编译 Script Hook V - GTA .NET 库。
I spent about 2 hours trying to figure out why it wouldn't work. Here is how I got it to build:
我花了大约 2 个小时试图弄清楚为什么它不起作用。这是我如何构建它:
I right clicked on the project and selected properties:
我右键单击项目并选择属性:
Under Configuration Properties -> General -> Platform Toolset
在配置属性 -> 常规 -> 平台工具集下
I selected the dropdown and selected the only other one available
我选择了下拉菜单并选择了唯一可用的另一个
(For me it was Visual Studio 2013 - Windows XP (v120_xp))
(对我来说是 Visual Studio 2013 - Windows XP (v120_xp))
After that I was able to fly my car normally:
之后我就可以正常驾驶我的车了:
Hope this helps someone else trying to do the same thing.
希望这可以帮助其他人尝试做同样的事情。
回答by kalmiya
I had the same issue with Visual Studio 2013 ( no Service-packs installed ). Apparently during installation it needs an active internet connection or the sdk-path might be missing.
我在 Visual Studio 2013 上遇到了同样的问题(没有安装 Service-packs)。显然,在安装过程中,它需要有效的互联网连接,否则 sdk-path 可能会丢失。
Just go into your control panel / programs / programs & features - and select "Microsoft Visual Studio xxx 2013", right-click-change and then "repair". It will take a few minutes but afterwards the sdk-path is correct.
只需进入您的控制面板/程序/程序和功能 - 并选择“Microsoft Visual Studio xxx 2013”,右键单击更改,然后“修复”。这将需要几分钟,但之后 sdk-path 是正确的。
回答by CoolOppo
I have been having this issue lately when trying to install certain Node.js packages! I finallyfixed it by adding the correct path to the registry variable!
我最近在尝试安装某些 Node.js 包时遇到了这个问题!我终于通过向注册表变量添加正确路径来修复它!
The easiest way to fix it is by setting it with a simple script.
修复它的最简单方法是使用简单的脚本对其进行设置。
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows]
"CurrentInstallFolder"="C:\Program Files (x86)\Windows Kits\8.1\"
This should fix it for any Windows 8.1 64-bit users, but if you have your Windows SDK installed in another directory, simply replace C:\Program Files (x86)\Windows Kits\8.1
with your respective directory. Here are a few places you can try:
这应该可以为任何 Windows 8.1 64 位用户修复它,但如果您将 Windows SDK 安装在另一个目录中,只需将其替换C:\Program Files (x86)\Windows Kits\8.1
为您各自的目录即可。您可以尝试以下几个地方:
- C:\Program Files (x86)\Windows Kits
- C:\Program Files (x86)\Microsoft SDKs\Windows
- C:\Program Files (x86)\Microsoft\Microsoft SDKs\Windows
- C:\Program Files (x86)\Windows 工具包
- C:\Program Files (x86)\Microsoft SDKs\Windows
- C:\Program Files (x86)\Microsoft\Microsoft SDKs\Windows
Note: Make sure to append the version as well to the end of the path; for example, 8.1
is at the end of my path. Basically, you need to get the full path to the Windows SDK and notjust the folder containing the main folder(s) for the Windows SDK.
注意:确保将版本也附加到路径的末尾;例如,8.1
在我路径的尽头。基本上,您需要获取 Windows SDK 的完整路径,而不仅仅是包含Windows SDK主文件夹的文件夹。
回答by osexp2003
回答by Ruslan
Try to invoke SetEnv.cmd manually in your command prompt:
尝试在命令提示符中手动调用 SetEnv.cmd:
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86
OR
或者
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64
回答by James Vespa
Installing Windows SDK v8.1 solved it for me.
安装 Windows SDK v8.1 为我解决了这个问题。
回答by Lesanus
For myself works this:
为我自己工作:
Check the value in "your".vcxproj <PlatformToolset>"some version"</PlatformToolset>
检查“您的”.vcxproj 中的值 <PlatformToolset>"some version"</PlatformToolset>
I know it is strange but:
我知道这很奇怪,但是:
I have installed VC2012 and VC2010 and I compile project from 2012 in 2010 with toolset "v110".
我已经安装了 VC2012 和 VC2010,并且我在 2010 年使用工具集“v110”编译了 2012 年的项目。
回答by Parvez
I was getting the error mentioned below when I was trying to install oracle driver for nodejs using npm install oracledb
. I have Windows 7.1 SP1 and I have installed Visual Studio 2015 community edition.
当我尝试使用npm install oracledb
. 我有 Windows 7.1 SP1 并且安装了 Visual Studio 2015 社区版。
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5):警告 MSB8003:无法从注册表中找到 WindowsSDKDir 变量。TargetFrameworkVersion 或 PlatformToolset 可能设置为无效的版本号。
Installing VC++ compiler as mentioned hereresolved the issue for me. For reference here is the action to do.
安装这里提到的 VC++ 编译器为我解决了这个问题。参考这里是要执行的操作。
You need to launch Visual studio, then do: file > new > project, in the window than opened, select "Model > Visual C++" and in the middle of the window you should see a button "install microsoft C++" or something like that, click on it and it will launch the install process for the C++ & Microsoft SDK. Once that's done it will work as expected !
您需要启动 Visual Studio,然后执行:文件 > 新建 > 项目,在打开的窗口中,选择“模型 > Visual C++”,在窗口中间您应该会看到一个按钮“安装 microsoft C++”或类似的东西,单击它,它将启动 C++ 和 Microsoft SDK 的安装过程。一旦完成,它将按预期工作!
回答by Pawan Agrawal
I was also facing the same issue.
我也面临同样的问题。
Installing Windows SDK v8.1 solved it for me.
安装 Windows SDK v8.1 为我解决了这个问题。
https://msdn.microsoft.com/en-us/windows/desktop/bg162891.aspx
https://msdn.microsoft.com/en-us/windows/desktop/bg162891.aspx
回答by Neenster
I had this same problem with VS2012. I had both 2013 and 2012 installed on my machine and experienced the issue after uninstalling VS2013 (which I was not using anymore due to expired license).
我在 VS2012 上遇到了同样的问题。我在我的机器上安装了 2013 和 2012,并在卸载 VS2013(由于许可证过期而不再使用)后遇到了这个问题。
The Registry keys linked above did not help me. In my opinion, independently from your VS version, the safest way to address this is to locate the batch file VS uses to load those macros, which seems to be VCVarsQueryRegistry.batin C:\Program Files (x86)\Microsoft Visual Studio [YOUR_VERSION].0\Common7\Tools.
上面链接的注册表项对我没有帮助。在我看来,独立于你的VS版本,以解决这一问题的最安全的方式是找到该批处理文件VS用于加载这些宏,这似乎是VCVarsQueryRegistry.bat在C:\ Program Files文件(x86)的\微软的Visual Studio [ YOUR_VERSION].0\Common7\Tools。
Look for the variable VS tells it is not defined. You might then find a snippet like:
查找变量 VS 告诉它未定义。然后你可能会找到一个片段,如:
@set WindowsSdkDir=
@call :GetWindowsSdkDirHelper32 HKLM > nul 2>&1
@if errorlevel 1 call :GetWindowsSdkDirHelper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetWindowsSdkDirHelper64 HKLM > nul 2>&1
@if errorlevel 1 call :GetWindowsSdkDirHelper64 HKCU > nul 2>&1
@exit /B 0
:GetWindowsSdkDirHelper32
@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0" /v "InstallationFolder"') DO (
@if "%%i"=="InstallationFolder" (
@SET "WindowsSdkDir=%%k"
)
)
@if "%WindowsSdkDir%"=="" exit /B 1
@exit /B 0
:GetWindowsSdkDirHelper64
@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.0" /v "InstallationFolder"') DO (
@if "%%i"=="InstallationFolder" (
@SET "WindowsSdkDir=%%k"
)
)
Which makes clear that WindowsSdkDir in a 64bit system is set by Registry value SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.0\InstallationFolderin either HKEY_CURRENT_USERor HKEY_LOCAL_MACHINEdepending on your configuration.
这清楚地表明 64 位系统中的 WindowsSdkDir 是由HKEY_CURRENT_USER或HKEY_LOCAL_MACHINE 中的注册表值SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.0\InstallationFolder 设置的,具体取决于您的配置。