rc.exe no longer found in VS 2015 Command Prompt

2019-01-29 20:59发布

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.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 (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 Kits\8.1\bin\x64\rc.exe
C:\Program Files (x86)\Windows Kits\8.1\bin\x86\rc.exe

and a VS 2017 command prompt:

> where rc.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64\rc.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 Kits\8.1\bin\x64
    
  • Inside a VS 2017 command prompt, PATH contains

    C:\Program Files (x86)\Windows Kits\10\bin\x64
    C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64
    
  • But inside a VS 2015 command prompt, PATH only contains

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

    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

10条回答
ら.Afraid
2楼-- · 2019-01-29 21:13

Specifying CMAKE_SYSTEM_VERSION=8.1 solved the problem for me.

查看更多
【Aperson】
3楼-- · 2019-01-29 21:14

Met the same problem with Windows 10 15063.608 (Windows SDK 10.0.15063.0). The solution working for me is the hard links creation for Windows 10 kit binaries x64 and x86 folders like shown below (use the command prompt with admin rights):

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"

(prior to running these commands just rename existing Windows Kits\10\bin\x64 and Windows Kits\10\bin\x86 folders - it looks like they are not in use.

查看更多
手持菜刀,她持情操
4楼-- · 2019-01-29 21:18

For whatever reason the built-in Tools (1.4.1) and Windows 10 SDK (10.0.14393) installer didn't work for me:

  1. C:\Program Files (x86)\Windows Kits\10\bin\x86 got populated mid-install (success!)
  2. ...then de-populated (sorrow!)
  3. And eventually the installer returned error -2147023293/0x80048646.

The "Windows 10 SDK (ver. 10.0.14393.795)" installer from the Windows SDK and emulator archive worked though: C:\Program Files (x86)\Windows Kits\10\bin\x86 gets and stays populated, including rc.exe.

Windows 7 x64, Visual Studio Professional 2015 Update 3.

查看更多
狗以群分
5楼-- · 2019-01-29 21:20

It's definitely not just you. I installed VS2017 yesterday and doing so seems to have produced the same problem on my end. I don't have a good solution (this should be reported to Microsoft as a bug) but I do have a hacky workaround.

I was able to copy rc.exe and rc.dll from

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

That resolved the issue for me. My hunch is that it's a registry key being overwritten but I haven't dug into it enough to be sure.

查看更多
爷、活的狠高调
6楼-- · 2019-01-29 21:23

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.0\VC\bin\amd64\vcvars64.bat

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

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

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 Kits\10\bin\10.0.15063.0\x64

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 Kits\10\bin\x64

Running rc -v on

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

and

C:\Program Files (x86)\Windows Kits\10\bin\x64\rc.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 Kits\10\bin\x64\rc.exe

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

查看更多
爷、活的狠高调
7楼-- · 2019-01-29 21:23

For anyone who gets stuck on this, one particular problem set is:

  1. get a new windows 10 PC
  2. install VS 2017 [*]
  3. uninstall VS 2017 and
  4. install VS 2015

If you do the above,

it seems that there is a bug or other behavior with the overall suite of Windows/VS installers.

There are basically it seems four problems MSFT have to fix (a) sometimes it just doesn't install rc.exe, (b) it doesn't install rc.exe if you "only" ask for the c++ stuff, you must ask for everything (c) the uninstall-install pipeline seems to be all messed up in various ways (d) even if it randomly installs rc.exe for you, it forgets or fouls-up the path.

:/

Long tedious story short, solutions seem to include one or more of

  1. basically install or re-install 10.0.10011.16384 (but only that one, NOT the two later ones)
  2. look around and see if rc.exe is plain, outright, not there. If so, install it (somewhere, anywhere)
  3. in VS, you'd think you can install "just" the c++ stuff, but no. In practice you MUST check yes to all the web, blah blah development stuff. This seems to give you "more hope" of getting rc.exe. After doing this, revisit point 2, as you may well still not have it.
  4. After doing 2 then 3 and likely 2 again, you likely STILL will not have it in your actual path. I would love to know which is the "best, natural" place to have it in your path, but that seems to be a lost cause. Just shove it in your path somewhere, anywhere.
  5. Create a simple cmake file somewhere - and test it works.

. . . . . .

[*] it may well come with VS 2017, and don't forget VS 2017 may annoyingly get installed with something else, Unity etc.

查看更多
登录 后发表回答