我刚刚安装了 Windows 10 Creators Update(版本 10.0.15063)。
我安装了多个版本的 Visual Studio(2012、2013、2015 和 2017)。我仅在几周前安装了 VS 2017。
问题
在“VS2015 x64 本机命令提示符”中运行时,CMake(版本 3.8.1)不再找到 C/C++ 编译器(在 VS 2017 命令提示符中运行时它 确实 可以正常工作)。
再生产
CMakeLists.txt
的内容:
project (test)
add_executable (test test.cpp)
( test.cpp
的内容无关。)
CMake 调用,在 VS2015 x64 本机命令提示符中:
> mkdir build
> cd build
> cmake -G "Visual Studio 14 2015 Win64" ..
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".
分析
查看 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\3.8.1\CompilerIdC\CompilerIdC.vcxproj]
rc.exe
(资源编译器)未找到。事实上,在同一个 VS 2015 命令提示符下:
> where rc.exe
INFO: Could not find files for the given pattern(s).
虽然它 可以 在 VS 2013 命令提示符中找到:
> where rc.exe
C:\Program Files (x86)\Windows Kits\8.1\bin\x64\rc.exe
C:\Program Files (x86)\Windows Kits\8.1\bin\x86\rc.exe
和 VS 2017 命令提示符:
> where rc.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64\rc.exe
检查各种VS命令提示符中 PATH
环境变量的内容:
- 在 VS 2013 命令提示符内,
PATH
包含
C:\Program Files (x86)\Windows Kits\8.1\bin\x64
- 在 VS 2017 命令提示符内,
PATH
包含
C:\Program Files (x86)\Windows Kits\10\bin\x64
C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64
- 但在 VS 2015 命令提示符中,
PATH
仅包含
C:\Program Files (x86)\Windows Kits\10\bin\x64
其中不包含 rc.exe
。
问题
这是一个已知问题还是特定于我的系统?
Windows 10 Creators Update 可能会在系统中安装、卸载或更改什么(可能与 Windows SDK 相关)会触发此问题?
什么是解决此问题的干净方法?
编辑:安装的 VS 2017 组件:
原文由 François Beaune 发布,翻译遵循 CC BY-SA 4.0 许可协议
花了一些时间在安装了 Win10 Creators Edition 和 VS2010、VS2013、VS2015 和 VS2017 的三台机器上查看这个问题,它在两台机器上工作,在第三台机器上失败。所有人都安装了 VS2015 Update 3,并且都应该使用相同的选项进行安装。
运行以下批处理文件
应该为 VS2015 x64 环境设置正确的环境。这应该添加
到路径。这是 rc.exe 应该在的地方。然而,在我失败的机器上, rc.exe 从这里丢失了,但它确实存在于
我回去感觉这是一个设置问题我重新运行了 VS2015 Update 3 设置并告诉它添加
Windows 和 Web 开发 -> 通用 Windows 应用程序开发工具 -> 工具 (1.4.1) 和 Windows 10 SDK (10.0.14393)
这导致 rc.exe 和相关文件出现在
运行 rc -v on
和
给出了相同的版本号 10.0.10011.16384
不知道为什么原始安装中缺少 rc.exe,但重新运行安装并添加其他 SDK 为我修复了它。看起来像
应该是默认的 rc.exe ,但它不是由以前的安装设置的。