27

We are having trouble compiling a project using CMake (v2.8.12) under Windows 7 64Bit using Visual Studio 2012. CMake gives us the following errors. We already tried starting Cmake from the Visual Studio Command Line using admin rights. There seems to have been a similar bug in CMake 2.8.11: http://www.cmake.org/Bug/view.php?id=14440

CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:446 (execute_process):
  execute_process given COMMAND argument with no value.
Call Stack (most recent call first):
  C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:48 (CMAKE_DETERMINE_COMPILER_ID_VENDOR)
  C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake:131 (CMAKE_DETERMINE_COMPILER_ID)
  CMakeLists.txt:2 (project)


The C compiler identification is unknown
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:446 (execute_process):
  execute_process given COMMAND argument with no value.
Call Stack (most recent call first):
  C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:48 (CMAKE_DETERMINE_COMPILER_ID_VENDOR)
  C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCXXCompiler.cmake:127 (CMAKE_DETERMINE_COMPILER_ID)
  CMakeLists.txt:2 (project)


The CXX compiler identification is unknown
Could NOT find SWIG (missing:  SWIG_EXECUTABLE SWIG_DIR) 
CMake Warning at src/CMakeLists.txt:44 (message):
  SWIG was not found.  You will not be able to compile for C#.


Configuring incomplete, errors occurred!
See also "C:/Users/hci/laser_control/CMakeFiles/CMakeOutput.log".
See also "C:/Users/hci/laser_control/CMakeFiles/CMakeError.log".
johnnyRose
  • 7,310
  • 17
  • 40
  • 61
user3110931
  • 271
  • 1
  • 3
  • 3
  • Well the error message is pretty clear. It does not know your compiler ID String. Was this ever working or where you just porting a project? Edit the appropriate files to add this compiler. – RedX Dec 17 '13 at 11:27
  • 2
    Did you use the correct generator? I mean "Visual Studio 11 is the correct generator for Visual Studio 2012" Do not use Visual Studio 12 as the generator. – drescherjm Dec 18 '13 at 13:49
  • I faced with the same problem when I ran CMake on a network drive. – ar2015 Aug 31 '18 at 11:19

15 Answers15

11

I had the same issue and fixed it running cmake as Admin

Fuvizzo
  • 261
  • 4
  • 8
  • 33
    Didn't help in my case. – BartoszKP Mar 19 '14 at 13:26
  • I was having the same issue when compiling SFML 2.1 using Visual C++ 2013 compiler. Running as Admin fixed it. – sjaustirni Jul 01 '14 at 13:48
  • I ran into the same problem after upgrading Windows SDK from 7.0a to 7.1. New version was put into C:\Program Files\ (I guess I took the 64bit version) and VS2012 C++ and CMake as well could not compile anymore. Running the Windows Control Panel | Programs and Functions | VS2012 | Repair did the trick, and VS and CMake run properly now. – Michbeckable Jul 28 '14 at 11:52
  • 1
    This solved it for me - but does anyone know _why_ this helps? – sparrowt Jun 29 '17 at 11:19
  • it worked,,. I am building llvm for jailbroken ios – Xin Mar 03 '20 at 21:32
11

Those error messages

The C compiler identification is unknown
The CXX compiler identification is unknown

means CMake did find or assume a compiler but it wasn't able to compile a simple test program.

Take a look at CMakeFiles\CMakeError.log and check the error message there to see:

  1. which compiler path/command line CMake did use
  2. what the error message calling the compiler was

    e.g. LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'

If you add --debug-trycompile to the cmake call CMake will even keep the files it has tried to test compile (so you can copy/paste/re-run the command line from the error log in your cmd shell).

The last time I had this problem ...

The last time I had this problem was when my Visual Studio 2012 Professional standard installation did not install any Windows SDK (the error log was showing an missing SDK header).

To verify your SDK installation e.g. check that you have any Resource Compiler installed. It should be in a path similar to:

C:\Program Files (x86)\Microsoft SDKs\Windows\v[some version]\bin\RC.Exe

Since I was missing this - or more accurate any SDK - I installed Windows 8.1 SDK (since Visual Studio 2012 does target Windows 8.x) and voila my CMake was able again to compile the (test) programs.

Reference

Florian
  • 39,996
  • 9
  • 133
  • 149
9

I was getting the terminal output:

The C compiler identification is unknown
The CXX compiler identification is unknown

I checked the CMakeError.log output:

\build\CMakeFiles\CMakeError.log

It showed the error:

warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found.

Going back to visual Studio I needed to install the Windows 10 SDK:

enter image description here

After installing the SDK and running cmake it showed:

Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.18363.
The C compiler identification is MSVC 19.28.29334.0
The CXX compiler identification is MSVC 19.28.29334.0

And built successfully!

Kim T
  • 5,770
  • 1
  • 52
  • 79
3

For some reason, deleting the build folder in my machine, solved the issue.

Juan José
  • 59
  • 1
2

I had similar problem also, if you are using Microsoft Visual Studio 2012, that might be because of update of KB2781514 is missing.

After I installed following update, CMake start to detect Visual Studio 2012 c/c++ compilers correctly.

http://www.microsoft.com/en-us/download/details.aspx?id=36020

Jifeng Zhang
  • 5,037
  • 4
  • 30
  • 43
2

I faced the same problem. Building and running a project from Visual Studio didn't work for me. However following worked for me:

  • Open command prompt for developers from Visual Studio tools.
  • Goto the directory where cmake.exe is present.
  • Run it.

Lets hope it works for you as well.

Asif Kazmi
  • 21
  • 2
1

cmake:

The cmake assume that you set g++ compiler path accurately.In case due any reason if it did't find compiler path{/usr/bin/g++} then it throw an error like:

           **The CXX compiler identification is unknown**

So given step will short out this error:

  • Locate your compiler CXX path{for g++ path under Linux is :/usr/bin/g++}

  • Set the Compiler Path and export it configuration: PATH=/usr/bin:$PATH;export PATH

  • Export compiler like : export CXX=/usr/bin/g++-7

Here we assume that g++,cmake,build-essential install in your Linux system...!!

0

Same problem here with cmake 2.8.12 and visual studio 10. Cmake may not be able to find the compiler. I solved the problem by uninstalling latest version and installed cmake 2.8.10.

Tonmoy
  • 557
  • 2
  • 6
  • 20
0

I just encounter with this issue, after I uninstalled some MS software. I fixed it by repair visual studio 2012. First go to [Control panel], then select visual studio and repair it,things will go right now.

wangdq
  • 1,874
  • 17
  • 26
0

Make sure you select the proper version of visual Studio. For example, Visual Studio 2012 is version 11.

Rahul Sood
  • 109
  • 1
  • 3
0

I had the same problem and I had to use the "File -> Delete Cache", since I accidentally configured CMake to use wrong visual studio version.

Andrey Rubshtein
  • 20,795
  • 11
  • 69
  • 104
0

If you use CMake 3.4.0, try upgrading to a newer version. A bug concerning this was fixed relatively recently (see the bug report).

Daniel Geier
  • 1
  • 1
  • 2
0

Make sure that you have installed Clang tools

Nightcap79
  • 620
  • 7
  • 13
0

open tools -> Get tools and features, select individual components, search cmake, then uninstall cmake and then re-install cmake, when complete, restart your computer.

0

I was seeing this on ubuntu - issue was cmake was assuming clang++ as c compiler.

CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler
    "/usr/bin/clang++-9"

To fix it, export C, C++ compiler paths:

 export CC=/usr/bin/clang
 export CXX=/usr/bin/clang++
brokenfoot
  • 11,083
  • 10
  • 59
  • 80