rc.exe不再在VS 2015命令提示符中find

我刚安装了Windows 10 Creators Update(版本10.0.15063)。

我安装了多个版本的Visual Studio(2012,2013,2015和2017)。 我几个星期前安装了VS 2017。

问题

CMake(版本3.8.1)在“VS2015 x64本机命令提示符”(在VS 2017命令提示符下运行时可以正常工作)内不再findC / C ++编译器。

再生产

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] 

没有findrc.exe (资源编译器)。 事实上,在相同的VS 2015命令提示符下:

 > where rc.exe INFO: Could not find files for the given pattern(s). 

在VS 2013命令提示符中find它时:

 > 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环境variables的内容:

  • 在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

问题

  1. 这是一个已知的问题还是特定于我的系统?

  2. Windows 10 Creators Update可能会在系统中安装,卸载或更改(可能是与Windows SDK相关的东西),从而引发此问题?

  3. 什么是解决这个干净的方法?

编辑:安装VS 2017组件:

安装了VS 2017组件

花了一些时间在三台安装了Win10 Creators Edition和VS2010,VS2013,VS2015和VS2017的机器上查看,在两台机器上运行,第三台机器运行失败。 所有的VS2015更新3和所有应该已经安装了相同的选项。

运行下面的批处理文件

 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat 

应该为VS2015 x64环境设置正确的环境。 这应该添加

 C:\Program Files (x86)\Windows Kits\10\bin\x64 

到PATH。 这是rc.exe应该在的地方。 然而,在我的失败的机器rc.exe从这里失踪,但它确实存在于

 C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64 

我回去,感觉这是一个设置问题,我重新运行了VS2015 Update 3设置,并告诉它添加

Windows和Web开发 – >通用Windows应用程序开发工具 – >工具(1.4.1)和Windows 10 SDK(10.0.14393)

这导致rc.exe和相关文件出现在

 C:\Program Files (x86)\Windows Kits\10\bin\x64 

运行rc -v

 C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64\rc.exe 

 C:\Program Files (x86)\Windows Kits\10\bin\x64\rc.exe 

给出了相同的版本号10.0.10011.16384

不知道为什么rc.exe从原来的安装丢失,但重新运行安装和添加其他SDK修复了我。 看起来像

 C:\Program Files (x86)\Windows Kits\10\bin\x64\rc.exe 

应该是默认的rc.exe,但它不是由以前的安装。

绝对不只是你。 我昨天安装了VS2017,这样做似乎在我的最后产生了同样的问题。 我没有一个好的解决方案(这应该作为一个bug报告给微软),但我有一个hacky解决方法。

我能够从中复制rc.exe和rc.dll

 C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64 to C:\Program Files (x86)\Windows Kits\10\bin\x86 

这为我解决了这个问题。 我的直觉是这是一个注册表键被覆盖,但我还没有深入到足以确定。

遇到与Windows 10 15063.608(Windows SDK 10.0.15063.0)相同的问题。 为我工作的解决方案是为Windows 10工具包二进制文件x64和x86文件夹创建硬链接,如下所示(使用带有管理员权限的命令提示符):

 mklink /J "C:\Program Files (x86)\Windows Kits\10\bin\x86" "C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x86" mklink /J "C:\Program Files (x86)\Windows Kits\10\bin\x64" "C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64" 

(在运行这些命令之前,只需重命名现有的Windows Kits\10\bin\x64Windows Kits\10\bin\x86文件夹 – 看起来他们没有被使用。

指定CMAKE_SYSTEM_VERSION=8.1解决了我的问题。