C++ 在 VS 2015 命令提示符中不再找到 rc.exe
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43847542/
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
rc.exe no longer found in VS 2015 Command Prompt
提问by Fran?ois Beaune
I just installed Windows 10 Creators Update (version 10.0.15063).
我刚刚安装了 Windows 10 创意者更新(版本 10.0.15063)。
I have multiple versions of Visual Studio installed (2012, 2013, 2015 and 2017). I installed VS 2017 only a couple weeks ago.
我安装了多个版本的 Visual Studio(2012、2013、2015 和 2017)。几周前我才安装了 VS 2017。
Problem
问题
CMake (version 3.8.1) no longer finds the C/C++ compiler when run inside a "VS2015 x64 Native Command Prompt" (it doeswork properly when run inside a VS 2017 command prompt).
在“VS2015 x64 本机命令提示符”中运行时,CMake(版本 3.8.1)不再找到 C/C++ 编译器(在 VS 2017 命令提示符中运行时它可以正常工作)。
Reproduction
再生产
Content of CMakeLists.txt
:
内容CMakeLists.txt
:
project (test)
add_executable (test test.cpp)
(Content of test.cpp
is irrelevant.)
(内容test.cpp
无关。)
CMake invocation, in a VS2015 x64 Native Command Prompt:
CMake 调用,在 VS2015 x64 本机命令提示符中:
> mkdir build
> cd build
> cmake -G "Visual Studio 14 2015 Win64" ..
CMake output:
CMake输出:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:1 (project):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:1 (project):
No CMAKE_CXX_COMPILER could be found.
-- Configuring incomplete, errors occurred!
See also "D:/dev/cmaketest/build/CMakeFiles/CMakeOutput.log".
See also "D:/dev/cmaketest/build/CMakeFiles/CMakeError.log".
Analysis
分析
The reason of the failure is clear when looking at CMakeFiles/CMakeError.log
:
查看失败的原因很清楚CMakeFiles/CMakeError.log
:
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe /c /nologo /W0 /WX- /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\" /Fd"Debug\vc140.pdb" /Gd /TC /errorReport:queue CMakeCCompilerId.c
CMakeCCompilerId.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj
LINK : fatal error LNK1158: cannot run 'rc.exe' [D:\dev\cmaketest\build\CMakeFiles.8.1\CompilerIdC\CompilerIdC.vcxproj]
rc.exe
(Resource Compiler) is not found. Indeed, in the same VS 2015 command prompt:
rc.exe
(资源编译器)未找到。事实上,在同一个 VS 2015 命令提示符中:
> where rc.exe
INFO: Could not find files for the given pattern(s).
While it isfound in a VS 2013 command prompt:
虽然它是在 VS 2013 命令提示符中找到的:
> where rc.exe
C:\Program Files (x86)\Windows Kits.1\bin\x64\rc.exe
C:\Program Files (x86)\Windows Kits.1\bin\x86\rc.exe
and a VS 2017 command prompt:
和 VS 2017 命令提示符:
> where rc.exe
C:\Program Files (x86)\Windows Kits\bin.0.15063.0\x64\rc.exe
Checking the content of the PATH
environment variables in various VS command prompts:
PATH
在各种VS命令提示符下检查环境变量的内容:
Inside a VS 2013 command prompt,
PATH
containsC:\Program Files (x86)\Windows Kits.1\bin\x64
Inside a VS 2017 command prompt,
PATH
containsC:\Program Files (x86)\Windows Kits\bin\x64 C:\Program Files (x86)\Windows Kits\bin.0.15063.0\x64
But inside a VS 2015 command prompt,
PATH
only containsC:\Program Files (x86)\Windows Kits\bin\x64
which does not contain
rc.exe
.
在 VS 2013 命令提示符中,
PATH
包含C:\Program Files (x86)\Windows Kits.1\bin\x64
在 VS 2017 命令提示符中,
PATH
包含C:\Program Files (x86)\Windows Kits\bin\x64 C:\Program Files (x86)\Windows Kits\bin.0.15063.0\x64
但是在 VS 2015 命令提示符中,
PATH
只包含C:\Program Files (x86)\Windows Kits\bin\x64
其中不包含
rc.exe
.
Questions
问题
Is this a known issue or is it specific to my system?
What could Windows 10 Creators Update possibly install, uninstall or alter in the system (perhaps something related to Windows SDKs) that would trigger this problem?
What is a clean way to resolve this?
这是已知问题还是特定于我的系统?
Windows 10 创意者更新可能会在系统中安装、卸载或更改哪些会触发此问题的内容(可能与 Windows SDK 相关)?
什么是解决这个问题的干净方法?
Edit: Installed VS 2017 components:
编辑:安装 VS 2017 组件:
回答by DaveCleland
Spent some time looking at this on three machines with Win10 Creators Edition and VS2010, VS2013, VS2015 and VS2017 installed, where it works on two machines and fails on the third. All had VS2015 Update 3 and all should have been installed with the same options.
花了一些时间在安装了 Win10 Creators Edition 和 VS2010、VS2013、VS2015 和 VS2017 的三台机器上查看此问题,它在两台机器上运行,在第三台上失败。全部都有 VS2015 Update 3,并且都应该使用相同的选项进行安装。
Running the following batch file
运行以下批处理文件
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat
should setup the correct environment for VS2015 x64 environment. This should add
应该为 VS2015 x64 环境设置正确的环境。这应该添加
C:\Program Files (x86)\Windows Kits\bin\x64
to the PATH. This is where rc.exeshould be. However on my failing machine rc.exewas missing from here, but it did exist in
到路径。这就是rc.exe应该在的地方。然而,在我失败的机器上,rc.exe从这里丢失,但它确实存在于
C:\Program Files (x86)\Windows Kits\bin.0.15063.0\x64
I went back and feeling like this was a setup issue I re-ran the VS2015 Update 3 setup and told it to add
我回去感觉这是一个设置问题我重新运行了 VS2015 Update 3 设置并告诉它添加
Windows and Web Development -> Universal Windows App Development Tools -> Tools (1.4.1) and Windows 10 SDK (10.0.14393)
Windows 和 Web 开发 -> 通用 Windows 应用程序开发工具 -> 工具 (1.4.1) 和 Windows 10 SDK (10.0.14393)
this caused rc.exeand related files to appear in
这导致rc.exe和相关文件出现在
C:\Program Files (x86)\Windows Kits\bin\x64
Running rc -von
运行RC -v上
C:\Program Files (x86)\Windows Kits\bin.0.15063.0\x64\rc.exe
and
和
C:\Program Files (x86)\Windows Kits\bin\x64\rc.exe
gave the same version number 10.0.10011.16384
给出了相同的版本号10.0.10011.16384
Not sure why rc.exe was missing from the original install, but re-running the install and adding the other SDK fixed it for me. It looks like
不知道为什么原始安装中缺少 rc.exe,但重新运行安装并添加其他 SDK 为我修复了它。看起来像
C:\Program Files (x86)\Windows Kits\bin\x64\rc.exe
should be the default rc.exebut it was not setup by a previous install.
应该是默认的rc.exe但它不是由以前的安装设置的。
回答by Falcon
It's definitely not just you. I installed VS2017 yesterday and doing so seems to have produced the same problem on my end. I don't have a good solution (this should be reported to Microsoft as a bug) but I do have a hacky workaround.
这绝对不仅仅是你。我昨天安装了 VS2017,这样做似乎对我产生了同样的问题。我没有好的解决方案(这应该作为错误报告给 Microsoft),但我确实有一个 hacky 解决方法。
I was able to copy rc.exe and rc.dll from
我能够从复制 rc.exe 和 rc.dll
C:\Program Files (x86)\Windows Kits\bin.0.15063.0\x64
to
C:\Program Files (x86)\Windows Kits\bin\x86
That resolved the issue for me. My hunch is that it's a registry key being overwritten but I haven't dug into it enough to be sure.
那为我解决了这个问题。我的预感是它是一个被覆盖的注册表项,但我还没有深入了解它。
回答by Victoria Zhislina
Met the same problem with Windows 10 15063.608 (Windows SDK 10.0.15063.0). The solution working for me is the hard links creation for Windows 10 kit binaries x64 and x86 folders like shown below (use the command prompt with admin rights):
在 Windows 10 15063.608 (Windows SDK 10.0.15063.0) 上遇到了同样的问题。对我有用的解决方案是为 Windows 10 工具包二进制文件 x64 和 x86 文件夹创建硬链接,如下所示(使用具有管理员权限的命令提示符):
mklink /J "C:\Program Files (x86)\Windows Kits\bin\x86" "C:\Program Files (x86)\Windows Kits\bin.0.15063.0\x86"
mklink /J "C:\Program Files (x86)\Windows Kits\bin\x64" "C:\Program Files (x86)\Windows Kits\bin.0.15063.0\x64"
(prior to running these commands just rename existing Windows Kits\10\bin\x64
and Windows Kits\10\bin\x86
folders - it looks like they are not in use.
(在运行这些命令之前,只需重命名现有文件夹Windows Kits\10\bin\x64
和Windows Kits\10\bin\x86
文件夹 - 看起来它们没有被使用。
P.S. mklink
is a CMD
command, not available under PowerShell
PSmklink
是一个CMD
命令,下不可用PowerShell
回答by genpfault
For whatever reason the built-in Tools (1.4.1) and Windows 10 SDK (10.0.14393)installer didn't work for me:
无论出于何种原因,内置工具 (1.4.1) 和 Windows 10 SDK (10.0.14393)安装程序对我不起作用:
C:\Program Files (x86)\Windows Kits\10\bin\x86
got populated mid-install (success!)- ...then de-populated (sorrow!)
- And eventually the installer returned error
-2147023293
/0x80048646
.
C:\Program Files (x86)\Windows Kits\10\bin\x86
在安装中填充(成功!)- ...然后人口减少(悲伤!)
- 最终安装程序返回错误
-2147023293
/0x80048646
。
The "Windows 10 SDK (ver. 10.0.14393.795)" installerfrom the Windows SDK and emulator archiveworked though: C:\Program Files (x86)\Windows Kits\10\bin\x86
gets and stays populated, including rc.exe
.
来自Windows SDK 和模拟器存档的“Windows 10 SDK(版本 10.0.14393.795)”安装程序虽然有效:C:\Program Files (x86)\Windows Kits\10\bin\x86
获取并保持填充,包括rc.exe
.
Windows 7 x64, Visual Studio Professional 2015 Update 3.
Windows 7 x64,Visual Studio Professional 2015 更新 3。
回答by Lars Bilke
Specifying CMAKE_SYSTEM_VERSION=8.1
solved the problem for me.
指定CMAKE_SYSTEM_VERSION=8.1
为我解决了问题。
回答by stijn
Similar problem with VS2017 Community 15.4.5 with Windows Sdk version 10.0.16299.0, but only for builds via TeamCity; builds from within VS work fine and so does building with MSBuild when starting from a VS developer command prompt. So this does not exactly answer the OP's question, but is so similar and this is one of the first search matches so I'll add it here.
VS2017 Community 15.4.5 与 Windows Sdk 版本 10.0.16299.0 的类似问题,但仅适用于通过 TeamCity 构建;从 VS 内部构建工作正常,从 VS 开发人员命令提示符开始时使用 MSBuild 构建也是如此。所以这并不能完全回答 OP 的问题,但非常相似,这是第一个搜索匹配项,所以我会在这里添加它。
Found a solution which does notrequire modifying the installation in any way (no linking/copying so less error-prone and easy to automate):
发现这并不溶液不要求修改安装以任何方式(没有链接/复制所以不易出错和易于实现自动化):
set the VisualStudioVersion
environment variable to 15.0
.
将VisualStudioVersion
环境变量设置为15.0
.
You could do this globally using the standard Windows gui for that (example for windows 10 here) but I'd rather strongly advise against it becaus it could interfere with other versions of VS, moreover it is not a change which is easily automated nor checked in into your build code and hence harder to reproduce omn different machines. A better alternative is to set this in the commandline where the build runs (cmd: set VisualStudioVersion=15.0
PS: $env:VisualStudioVersion = '15.0'
in TeamCity: add env.VisualStudioVersion
Parameter). Another alternative is to pass this directory to MSBuild as a property (pass /p:VisualStudioVersion=15.0
or in teamCity add system.VisualStudioVersion
).
您可以使用标准的 Windows gui 全局执行此操作(例如此处的Windows 10 ),但我强烈建议不要这样做,因为它可能会干扰 VS 的其他版本,而且它不是一个易于自动化或检查的更改进入您的构建代码,因此更难重现所有不同的机器。更好的选择是在构建运行的命令行中设置它(cmd:set VisualStudioVersion=15.0
PS:$env:VisualStudioVersion = '15.0'
在 TeamCity:添加env.VisualStudioVersion
参数)。另一种选择是将此目录作为属性传递给 MSBuild(传递/p:VisualStudioVersion=15.0
或在 teamCity add 中system.VisualStudioVersion
)。
回答by yezhiyun
- run your online installer vs_community2017.exe.
- select modify your VS2017
- select desktop development with C++
- select Windows 10 SDK(my version is 10.0.10586) and install it
- 运行您的在线安装程序 vs_community2017.exe。
- 选择修改你的VS2017
- 选择使用 C++ 进行桌面开发
- 选择Windows 10 SDK(我的版本是10.0.10586)并安装它
Run VS2015 command prompt:
运行 VS2015 命令提示符:
> where rc
> C:\Program Files (x86)\Windows Kits\bin\x64\rc.exe
> C:\Program Files (x86)\Windows Kits\bin\x86\rc.exe
It seems that vs2017 default installs the newest SDK, and Overwrite old versions.
貌似vs2017默认安装最新的SDK,覆盖旧版本。
回答by Fattie
For anyone who gets stuck on this, one particular problem set is:
对于任何陷入困境的人来说,一个特定的问题集是:
- get a new windows 10 PC
- install VS 2017[*]
- uninstallVS 2017 and
- install VS 2015
- 获得一台新的Windows 10 PC
- 安装 VS 2017[*]
- 卸载VS 2017 和
- 安装 VS 2015
If you do the above,
如果你做到了以上,
it seems that there is a bug or other behavior with the overall suite of Windows/VS installers.
整个 Windows/VS 安装程序套件似乎存在错误或其他行为。
There are basically it seems four problems MSFT have to fix (a) sometimes it just doesn't install rc.exe, (b) it doesn't install rc.exe if you "only" ask for the c++ stuff, you must ask for everything (c) the uninstall-install pipeline seems to be all messed up in various ways (d) even if it randomly installs rc.exe for you, it forgets or fouls-up the path.
基本上似乎有四个问题 MSFT 必须解决(a)有时它只是不安装 rc.exe,(b)如果你“只”要求 C++ 的东西,它不会安装 rc.exe,你必须问对于所有事情 (c) 卸载-安装管道似乎都以各种方式搞砸了 (d) 即使它为您随机安装 rc.exe,它也会忘记或弄乱路径。
:/
:/
Long tedious story short, solutions seem to include one or moreof
龙乏味的故事,总之,解决方案似乎包括一个或一个以上的
- basically install or re-install 10.0.10011.16384 (but only that one, NOT the two later ones)
- look around and see if rc.exe is plain, outright, not there. If so, install it (somewhere, anywhere)
- in VS, you'd think you can install "just" the c++ stuff, but no. In practice you MUST check yes to all the web, blah blah development stuff. This seems to give you "more hope" of getting rc.exe. After doing this, revisit point 2, as you may well still not have it.
- After doing 2 then 3 and likely 2 again, you likely STILL will not have it in your actual path. I would love to know which is the "best, natural" place to have it in your path, but that seems to be a lost cause. Just shove it in your path somewhere, anywhere.
- Create a simple cmake file somewhere - and test it works.
- 基本上安装或重新安装 10.0.10011.16384 (但只有那个,而不是后面的两个)
- 环顾四周,看看 rc.exe 是否是简单的,完全的,而不是那里。如果是这样,安装它(某处,任何地方)
- 在 VS 中,你会认为你可以“只”安装 C++ 的东西,但不能安装. 在实践中,您必须对所有网络,等等开发内容都勾选是。这似乎给了您获得 rc.exe 的“更多希望”。完成此操作后,请重新访问第 2 点,因为您可能仍然没有它。
- 在执行 2 然后 3 并且可能再次执行 2 之后,您可能仍然不会在您的实际路径中使用它。我很想知道在你的道路上哪个是“最好的、自然的”地方,但这似乎是一个失败的原因。只需将它推到您的路径中的某个地方,任何地方。
- 在某处创建一个简单的 cmake 文件 - 并测试它是否有效。
. . . . . .
. . . . . .
[*] it may well come with VS 2017, and don't forget VS 2017 may annoyingly get installed with something else, Unity etc.
[*] 它很可能随 VS 2017 一起提供,并且不要忘记 VS 2017 可能会烦人地安装其他东西,例如 Unity 等。
回答by kwes
I had the exact same problem. Multiple Visual studio versions, including 2015 and 2017. My solution was to run the cmake command from 2017 developer command prompt, and specify the 2015 visual studio version with:
我有同样的问题。多个 Visual Studio 版本,包括 2015 和 2017。我的解决方案是从 2017 开发人员命令提示符运行 cmake 命令,并指定 2015 Visual Studio 版本:
cmake -G "Visual Studio 14 2015" ..
cmake -G "Visual Studio 14 2015" ..
回答by N3UR0CHR0M
Open "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat" in a text editor in administrator mode and change the line
以管理员模式在文本编辑器中打开“C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat”并更改行
@if not "%WindowsSdkDir%" == "" @set PATH=%WindowsSdkDir%bin\x86;%PATH%
@if not "%WindowsSdkDir%" == "" @set PATH=%WindowsSdkDir%bin\x86;%PATH%
to
到
@if not "%WindowsSdkDir%" == "" @set PATH=%WindowsSdkDir%bin\x86;%WindowsSdkDir%bin\%WindowsSDKVersion%x86;%PATH%
@if not "%WindowsSdkDir%" == "" @set PATH=%WindowsSdkDir%bin\x86;%WindowsSdkDir%bin\%WindowsSDKVersion%x86;%PATH%