【问题标题】:The CXX compiler identification is unknownCXX 编译器标识未知
【发布时间】:2014-01-05 03:19:54
【问题描述】:

我们在使用 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".

【问题讨论】:

  • 嗯,错误信息很清楚。它不知道您的编译器 ID 字符串。这是否曾经有效,或者您只是在哪里移植项目?编辑相应的文件以添加此编译器。
  • 您是否使用了正确的生成器?我的意思是“Visual Studio 11 是 Visual Studio 2012 的正确生成器”不要使用 Visual Studio 12 作为生成器。
  • 我在网络驱动器上运行 CMake 时遇到了同样的问题。

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


【解决方案1】:

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

【讨论】:

  • 对我没有帮助。
  • 我在使用 Visual C++ 2013 编译器编译 SFML 2.1 时遇到了同样的问题。以管理员身份运行修复了它。
  • 我在将 Windows SDK 从 7.0a 升级到 7.1 后遇到了同样的问题。新版本被放入 C:\Program Files\ (我想我拿了 64 位版本)和 VS2012 C++ 和 CMake 也无法编译了。运行 Windows 控制面板 |程序和功能 | VS2012 |修复成功了,VS 和 CMake 现在可以正常运行了。
  • 这为我解决了这个问题 - 但有人知道为什么这有帮助吗?
  • 它成功了,,。我正在为越狱的 ios 构建 llvm ?
【解决方案2】:

那些错误信息

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

表示 CMake 确实找到或假设了一个编译器,但它无法编译一个简单的测试程序。

查看CMakeFiles\CMakeError.log 并检查那里的错误消息以查看:

  1. CMake 使用了哪个编译器路径/命令行
  2. 调用编译器的错误信息是什么

    例如LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'

如果您将--debug-trycompile 添加到cmake 调用中,CMake 甚至会保留它尝试编译的文件(因此您可以从cmd 中的错误日志中复制/粘贴/重新运行命令行壳)。

我上次遇到这个问题...

我上次遇到此问题是在我的 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 能够再次编译(测试)程序。

参考

【讨论】:

    【解决方案3】:

    我得到了终端输出:

    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
    

    并且构建成功!

    【讨论】:

      【解决方案4】:

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

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

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

      【讨论】:

        【解决方案5】:

        我遇到了同样的问题。从 Visual Studio 构建和运行项目对我不起作用。但是以下对我有用:

        • 从 Visual Studio 工具中为开发人员打开命令提示符。
        • 转到 cmake.exe 所在的目录。
        • 运行它。

        希望它也对你有用。

        【讨论】:

          【解决方案6】:

          cmake

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

                     **The CXX compiler identification is unknown**
          

          所以给定的步骤会缩短这个错误:

          • 找到你的编译器 CXX 路径{for g++ 路径在 Linux 下是:/usr/bin/g++}

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

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

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

          【讨论】:

            【解决方案7】:

            由于某种原因,删除了我机器中的 build 文件夹,解决了这个问题。

            【讨论】:

              【解决方案8】:

              cmake 2.8.12 和 Visual Studio 10 也存在同样的问题。Cmake 可能无法找到编译器。我通过卸载最新版本并安装了 cmake 2.8.10 解决了这个问题。

              【讨论】:

                【解决方案9】:

                我只是在卸载一些 MS 软件后遇到这个问题。 我通过修复视觉工作室 2012 修复了它。 先到【控制面板】,然后选择visual studio,修复一下,马上就好了。

                【讨论】:

                  【解决方案10】:

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

                  【讨论】:

                    【解决方案11】:

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

                    【讨论】:

                      【解决方案12】:

                      如果您使用 CMake 3.4.0,请尝试升级到较新的版本。与此相关的错误是最近修复的(请参阅bug report)。

                      【讨论】:

                        【解决方案13】:

                        确保您已安装 Clang 工具

                        【讨论】:

                          【解决方案14】:

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

                          【讨论】:

                            【解决方案15】:

                            我在 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++
                            

                            【讨论】:

                              猜你喜欢
                              • 2016-03-04
                              • 2022-07-12
                              • 2023-03-16
                              • 1970-01-01
                              • 1970-01-01
                              • 1970-01-01
                              • 1970-01-01
                              • 1970-01-01
                              • 1970-01-01
                              相关资源
                              最近更新 更多