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

新手上路,请多包涵

我刚刚安装了 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

问题

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

  2. Windows 10 Creators Update 可能会在系统中安装、卸载或更改什么(可能与 Windows SDK 相关)会触发此问题?

  3. 什么是解决此问题的干净方法?

编辑:安装的 VS 2017 组件:

已安装 VS 2017 组件

原文由 François Beaune 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 873
2 个回答

花了一些时间在安装了 Win10 Creators Edition 和 VS2010、VS2013、VS2015 和 VS2017 的三台机器上查看这个问题,它在两台机器上工作,在第三台机器上失败。所有人都安装了 VS2015 Update 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

到路径。这是 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 on

 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 ,但它不是由以前的安装设置的。

原文由 DaveCleland 发布,翻译遵循 CC BY-SA 3.0 许可协议

在尝试安装 > py -3.11 -m pip zodb 后,我得到了那个讨厌的 LNK1158 错误。

我在以下位置有 VC 文件:

主机目标资源编译器版本 10.0.10011.16384

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

x64 x64 “C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\rcdll.dll”

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

x64 x86 “C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86\rcdll.dll”

主机目标链接器版本 14.00.24245.0

x64 x64 “C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe”

x86 x86 “C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe”

x64 x86 “C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64_x86\link.exe”

x86 x64 “C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe”

LINK 需要 RC 用于来自 persistent-4.9.1.tar.gz 的 cPersist

Setup.py 为目标 Python 3.11.0rc2 64 位运行 x86_amd64 工具

=> 需要将x64-x64 rc.exe 和rcdll.dll 复制到x86_amd64 目录下

因为我很懒 - 快速 XCOPY 就足够了,然后再尝试新的:

PS > py -3.11 -m pip install zodb

… 之后 …

PS > # 没有错误 - 我现在很开心!

原文由 Pekka Ylönen 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题