CXX编译器标识未知

时间:2013-12-17 11:26:05

标签: c++ visual-studio-2012 cmake

我们在使用Visual Studio 2012在Windows 7 64Bit下使用CMake(v2.8.12)编译项目时遇到问题.CMake给出了以下错误。我们已经尝试使用管理员权限从Visual Studio命令行启动Cmake。在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".

14 个答案:

答案 0 :(得分:10)

我遇到了同样的问题并修复了以管理员身份运行cmake

答案 1 :(得分:3)

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

答案 2 :(得分:2)

我也有类似的问题,如果你使用的是Microsoft Visual Studio 2012,可能是因为 KB2781514 的更新缺失了。

安装以下更新后,CMake开始正确检测Visual Studio 2012 c / c ++编译器。

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

答案 3 :(得分:1)

make

该cmake假定您正确设置了g ++编译器路径。如果由于某种原因而找不到编译器路径{/ usr / bin / g ++},则会抛出类似以下错误:

           **The CXX compiler identification is unknown**

因此,执行给定步骤将缩短此错误:

  • 找到编译器的CXX路径{对于Linux下的g ++路径为:/ usr / bin / g ++}

  • 设置编译器路径并导出其配置: PATH = / usr / bin:$ PATH; export PATH

  • 导出编译器,例如: export CXX = / usr / bin / g ++-7

这里我们假设 g ++,cmake,build-essential 已安装在您的Linux系统中... !!

答案 4 :(得分:1)

我正在获取终端输出:

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

我检查了CMakeError.log输出:

\build\CMakeFiles\CMakeError.log

它显示了错误:

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

回到visual Studio,我需要安装Windows 10 SDK:

enter image description here

在安装SDK并运行cmake之后,它显示:

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

并成功构建!

答案 5 :(得分:0)

与cmake 2.8.12和visual studio 10相同的问题.Cmake可能无法找到编译器。我通过卸载最新版本并安装了cmake 2.8.10解决了这个问题。

答案 6 :(得分:0)

在我卸载了一些MS软件之后,我刚刚遇到这个问题。 我通过修复视觉工作室2012修复它。 首先进入[控制面板],然后选择视觉工作室并进行修复,现在就可以了。

答案 7 :(得分:0)

确保选择正确版本的Visual Studio。 例如,Visual Studio 2012是版本11。

答案 8 :(得分:0)

我遇到了同样的问题而我不得不使用"File -> Delete Cache",因为我不小心将CMake配置为使用错误的visual studio版本。

答案 9 :(得分:0)

如果您使用CMake 3.4.0,请尝试升级到更新版本。有关此问题的错误最近已得到修复(请参阅bug report)。

答案 10 :(得分:0)

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.

答案 11 :(得分:0)

确保已安装Clang工具

答案 12 :(得分:0)

打开工具->获取工具和功能,选择单个组件,搜索 cmake ,然后卸载cmake,然后重新安装cmake,完成后,重新启动计算机。

答案 13 :(得分:0)

我在 ubuntu 上看到了这个 - 问题是 cmake 假设 clang++ 作为 c 编译器。

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

要修复它,请导出 C、C++ 编译器路径:

 export CC=/usr/bin/clang
 export CXX=/usr/bin/clang++