[英]The CXX compiler identification is unknown
我们在使用 CMake (v2.8.12) 在 Windows 7 64Bit 下使用 Visual Studio 2012 编译项目时遇到问题。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".
那些错误信息
The C compiler identification is unknown
The CXX compiler identification is unknown
意味着 CMake 确实找到或假设了一个编译器,但它无法编译一个简单的测试程序。
查看CMakeFiles\\CMakeError.log
并检查那里的错误消息以查看:
调用编译器的错误信息是什么
例如LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'
如果您将--debug-trycompile
添加到cmake
调用中,CMake 甚至会保留它尝试测试编译的文件(因此您可以从cmd
shell 的错误日志中复制/粘贴/重新运行命令行)。
上次遇到这个问题...
我最后一次遇到这个问题是我的 Visual Studio 2012 Professional 标准安装没有安装任何 Windows SDK(错误日志显示缺少 SDK 标头)。
验证您的 SDK 安装,例如检查您是否安装了任何资源编译器。 它应该位于类似于以下内容的路径中:
C:\Program Files (x86)\Microsoft SDKs\Windows\v[some version]\bin\RC.Exe
由于我错过了这个 - 或者更准确的任何 SDK - 我安装了Windows 8.1 SDK (因为 Visual Studio 2012 确实针对 Windows 8.x),瞧,我的 CMake 能够再次编译(测试)程序。
参考
我遇到了同样的问题并修复了它以管理员身份运行 cmake
我得到了终端输出:
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:
安装 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
并成功构建!
我也有类似的问题,如果您使用的是 Microsoft Visual Studio 2012,那可能是因为缺少KB2781514的更新。
安装以下更新后,CMake 开始正确检测 Visual Studio 2012 c/c++ 编译器。
http://www.microsoft.com/en-us/download/details.aspx?id=36020
我遇到了同样的问题。 从 Visual Studio 构建和运行项目对我不起作用。 但是以下对我有用:
希望它也适用于您。
出于某种原因,删除我机器中的构建文件夹解决了这个问题。
制作:
cmake 假设您准确设置了 g++ 编译器路径。如果由于任何原因没有找到编译器路径{/usr/bin/g++},则会抛出如下错误:
**The CXX compiler identification is unknown**
所以给定的步骤会缩短这个错误:
找到你的编译器CXX路径{Linux下的g++路径是:/usr/bin/g++}
设置编译器路径并导出它的配置: PATH=/usr/bin:$PATH;export PATH
这里我们假设在你的 Linux 系统中安装了g++,cmake,build-essential ...!!
cmake 2.8.12 和 Visual Studio 10 也有同样的问题。Cmake 可能找不到编译器。 我通过卸载最新版本并安装了 cmake 2.8.10 解决了这个问题。
在我卸载了一些 MS 软件后,我刚刚遇到了这个问题。 我通过repair Visual Studio 2012 修复了它。首先进入[控制面板],然后选择visual studio 并修复它,现在一切都会好起来的。
确保选择正确版本的 Visual Studio。 例如,Visual Studio 2012 是版本 11。
我遇到了同样的问题,我不得不使用"File -> Delete Cache"
,因为我不小心将 CMake 配置为使用错误的 Visual Studio 版本。
确保您已安装 Clang 工具
打开工具 -> 获取工具和功能,选择单个组件,搜索cmake ,然后卸载 cmake,然后重新安装 cmake,完成后重新启动计算机。
我在 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++
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.