Reputation: 3751
I am trying to use cmake for the first time to compile an old c project with Visual Studio 2015 however I keep getting c compiler is unknown. The error from cmake is as following;
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
Microsoft (R) Build Engine version 14.0.25123.0
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 23/06/2016 14:46:48.
Project "D:\Modules\cmake-test\build\CMakeFiles\3.6.0- rc3\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /nologo /W0 /WX- /Od /Oy- /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TC /analyze- /errorReport:queue CMakeCCompilerId.c
CMakeCCompilerId.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\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:X86 /SAFESEH Debug\CMakeCCompilerId.obj
LINK : fatal error LNK1158: cannot run 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\rc.exe' [D:\Modules\cmake-test\build\CMakeFiles\3.6.0-rc3\CompilerIdC\CompilerIdC.vcxproj]
Done Building Project "D:\Modules\cmake-test\build\CMakeFiles\3.6.0-rc3\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED.
Build FAILED.
"D:\Modules\cmake-test\build\CMakeFiles\3.6.0-rc3\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1158: cannot run 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\rc.exe' [D:\Modules\cmake-test\build\CMakeFiles\3.6.0-rc3\CompilerIdC\CompilerIdC.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.39
I have looked at these answers but not found a working solution.
Cmake Visual Studio 2015 Identification Unknown
CMake cannot identify C compiler from installed Visual Studio 2015
CMake does not find Visual C++ compiler
C compiler identification is unknown despite setting CC and CXX variables
The command I am using is
cmake -G "Visual Studio 14 2015" .
I have tried both 3.6.0-rc3 and 3.5.2 versions of cmake.
I got rc.exe on my path by following instructions from this question.
Visual Studio can't build due to rc.exe
Any help would be greatly appreciated!
Upvotes: 2
Views: 3102
Reputation: 9206
Go to MSVC setup from control panel, modify the installation and set this flag
(for me installing SDK from M$ website strangely didn't help)
Upvotes: 0