c语言编译后找不到exe,在VS 2015命令提示符中找不到c – rc.exe
我剛剛安裝了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的內容無關緊要.)
在VS2015 x64本機命令提示符中進行CMake調用:
> 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.
問題
>這是一個已知問題還是特定于我的系統?
> Windows 10 Creators Update可能會在系統中安裝,卸載或更改(可能是與Windows SDK相關的東西)會觸發此問題?
>什么是解決這個問題的干凈方法?
編輯:安裝VS 2017組件:
總結
以上是生活随笔為你收集整理的c语言编译后找不到exe,在VS 2015命令提示符中找不到c – rc.exe的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 皮卡丘代表什么意思 皮卡丘代表啥意思
- 下一篇: c语言中Gretchen函数的功能,听过