2

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!

Community
  • 1
  • 1
simon-p-r
  • 3,623
  • 2
  • 20
  • 35
  • Can you please give the `cmake` command line you have tried? Looks like `nmake`. – Florian Jun 23 '16 at 14:10
  • Possible duplicate of: http://stackoverflow.com/questions/25941858/c-compiler-identification-is-unknown-despite-setting-cc-and-cxx-variables – Mirakurun Jun 23 '16 at 14:25
  • Updated question as have tried that link already – simon-p-r Jun 23 '16 at 14:32
  • @Florian I have updated question – simon-p-r Jun 23 '16 at 14:38
  • The error says `cannot run 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\rc.exe'`. Can you try from the command line? – Florian Jun 23 '16 at 14:43
  • Yes I am running commands from visual studio command prompt, I believe it maybe issue with spaces in path but not sure – simon-p-r Jun 23 '16 at 14:46
  • What's your CMake version? It has be more recent than the VS you want to detect. – usr1234567 Jun 23 '16 at 15:33
  • Update question to show which versions of cmake I have tried. – simon-p-r Jun 23 '16 at 16:44
  • The error message is about `rc.exe`, which is part of the Windows SDK (e.g. `C:\Program Files (x86)\Windows Kits\8.1\bin\x86\rc.exe`). So something maybe broken in your Visual Studio/SDK installation (try to re-install the Windows SDK or see e.g. [here](http://stackoverflow.com/questions/14372706/visual-studio-cant-build-due-to-rc-exe)). – Florian Jun 23 '16 at 20:45
  • @Florian thanks but I have already tried this, I have got rc.exe on my path so not sure why cmake can't find it. – simon-p-r Jun 23 '16 at 20:52
  • I don't think this is a specific CMake problem: `link.exe` can't find `rc.exe`. If you google for ["LINK : fatal error LNK1158: cannot run rc.exe"](https://www.google.com/search?q=LINK%20%3A%20fatal%20error%20LNK1158%3A%20cannot%20run%20rc.exe&rct=j) you get several suggestions what could be wrong. – Florian Jun 24 '16 at 10:40

1 Answers1

0

Go to MSVC setup from control panel, modify the installation and set this flag

enter image description here

(for me installing SDK from M$ website strangely didn't help)

Stepan Yakovenko
  • 8,670
  • 28
  • 113
  • 206