Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

c++ - rc.exe no longer found in VS 2015 Command Prompt

I just installed Windows 10 Creators Update (version 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.

Problem

CMake (version 3.8.1) no longer finds the C/C++ compiler when run inside a "VS2015 x64 Native Command Prompt" (it does work properly when run inside a VS 2017 command prompt).

Reproduction

Content of CMakeLists.txt:

project (test)
add_executable (test test.cpp)

(Content of test.cpp is irrelevant.)

CMake invocation, in a VS2015 x64 Native Command Prompt:

> mkdir build
> cd build
> cmake -G "Visual Studio 14 2015 Win64" ..

CMake output:

-- 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:

ClCompile:
  C:Program Files (x86)Microsoft Visual Studio 14.0VCinx86_amd64CL.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"Debugvc140.pdb" /Gd /TC /errorReport:queue CMakeCCompilerId.c
  CMakeCCompilerId.c
Link:
  C:Program Files (x86)Microsoft Visual Studio 14.0VCinx86_amd64link.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 DebugCMakeCCompilerId.obj
LINK : fatal error LNK1158: cannot run 'rc.exe' [D:devcmaketestuildCMakeFiles3.8.1CompilerIdCCompilerIdC.vcxproj]

rc.exe (Resource Compiler) is not found. Indeed, in the same VS 2015 command prompt:

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

While it is found in a VS 2013 command prompt:

> where rc.exe
C:Program Files (x86)Windows Kits8.1inx64
c.exe
C:Program Files (x86)Windows Kits8.1inx86
c.exe

and a VS 2017 command prompt:

> where rc.exe
C:Program Files (x86)Windows Kits10in10.0.15063.0x64
c.exe

Checking the content of the PATH environment variables in various VS command prompts:

  • Inside a VS 2013 command prompt, PATH contains

    C:Program Files (x86)Windows Kits8.1inx64
    
  • Inside a VS 2017 command prompt, PATH contains

    C:Program Files (x86)Windows Kits10inx64
    C:Program Files (x86)Windows Kits10in10.0.15063.0x64
    
  • But inside a VS 2015 command prompt, PATH only contains

    C:Program Files (x86)Windows Kits10inx64
    

    which does not contain rc.exe.

Questions

  1. Is this a known issue or is it specific to my system?

  2. 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?

  3. What is a clean way to resolve this?

Edit: Installed VS 2017 components:

VS 2017 components installed

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

Running the following batch file

C:Program Files (x86)Microsoft Visual Studio 14.0VCinamd64vcvars64.bat

should setup the correct environment for VS2015 x64 environment. This should add

C:Program Files (x86)Windows Kits10inx64

to the PATH. This is where rc.exe should be. However on my failing machine rc.exe was missing from here, but it did exist in

C:Program Files (x86)Windows Kits10in10.0.15063.0x64

I went back and feeling like this was a setup issue I re-ran the VS2015 Update 3 setup and told it to add

Windows and Web Development -> Universal Windows App Development Tools -> Tools (1.4.1) and Windows 10 SDK (10.0.14393)

this caused rc.exe and related files to appear in

C:Program Files (x86)Windows Kits10inx64

Running rc -v on

C:Program Files (x86)Windows Kits10in10.0.15063.0x64
c.exe

and

C:Program Files (x86)Windows Kits10inx64
c.exe

gave the same version number 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

C:Program Files (x86)Windows Kits10inx64
c.exe

should be the default rc.exe but it was not setup by a previous install.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...