我刚刚安装了 Windows 10 创意者更新(版本 10.0.15063)。
我安装了多个版本的 Visual Studio(2012、2013、2015 和 2017)。我几周前才安装了 VS 2017。
Problem
CMake(版本 3.8.1)在“VS2015 x64 本机命令提示符”内运行时不再找到 C/C++ 编译器(它does在 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".
Analysis
失败原因一看就清楚了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).
虽然它is在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
检查内容PATH
各种VS命令提示符中的环境变量:
-
在 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 组件: