C++ CXX 编译器标识未知
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20632860/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The CXX compiler identification is unknown
提问by user3110931
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
我们在使用 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".
回答by Fuvizzo
I had the same issue and fixed it running cmake as Admin
我遇到了同样的问题并修复了它以管理员身份运行 cmake
回答by Florian
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.
意味着 CMake 确实找到或假设了一个编译器,但它无法编译一个简单的测试程序。
Take a look at CMakeFiles\CMakeError.log
and check the error message there to see:
查看CMakeFiles\CMakeError.log
并检查那里的错误消息以查看:
- which compiler path/command line CMake did use
what the error message calling the compiler was
e.g.
LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'
- CMake 确实使用了哪个编译器路径/命令行
调用编译器的错误消息是什么
例如
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).
如果您添加--debug-trycompile
到cmake
调用中,CMake 甚至会保留它尝试测试编译的文件(因此您可以从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).
我最后一次遇到这个问题是我的 Visual Studio 2012 Professional 标准安装没有安装任何 Windows SDK(错误日志显示缺少 SDK 标头)。
To verify your SDK installation e.g. check that you have any Resource Compiler installed. It should be in a path similar to:
验证您的 SDK 安装,例如检查您是否安装了任何资源编译器。它应该位于类似于以下内容的路径中:
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.
由于我错过了这个 - 或者更准确的任何 SDK - 我安装了Windows 8.1 SDK(因为 Visual Studio 2012 确实针对 Windows 8.x),瞧,我的 CMake 能够再次编译(测试)程序。
Reference
参考
回答by Jifeng Zhang
I had similar problem also, if you are using Microsoft Visual Studio 2012, that might be because of update of KB2781514is missing.
我也有类似的问题,如果您使用的是 Microsoft Visual Studio 2012,那可能是因为缺少KB2781514的更新。
After I installed following update, CMake start to detect Visual Studio 2012 c/c++ compilers correctly.
安装以下更新后,CMake 开始正确检测 Visual Studio 2012 c/c++ 编译器。
http://www.microsoft.com/en-us/download/details.aspx?id=36020
http://www.microsoft.com/en-us/download/details.aspx?id=36020
回答by Asif Kazmi
I faced the same problem. Building and running a project from Visual Studio didn't work for me. However following worked for me:
我遇到了同样的问题。从 Visual Studio 构建和运行项目对我不起作用。但是以下对我有用:
- Open command prompt for developers from Visual Studio tools.
- Goto the directory where cmake.exe is present.
- Run it.
- 从 Visual Studio 工具为开发人员打开命令提示符。
- 转到存在 cmake.exe 的目录。
- 运行。
Lets hope it works for you as well.
希望它也适用于您。
回答by Pramod Maurya
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:
cmake 假设您准确设置了 g++ 编译器路径。如果由于任何原因没有找到编译器路径{/usr/bin/g++},则会抛出如下错误:
**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
找到你的编译器CXX路径{Linux下的g++路径是:/usr/bin/g++}
设置编译器路径并导出它的配置:PATH=/usr/bin:$PATH;export PATH
- 导出编译器如:export CXX=/usr/bin/g++-7
Here we assume that g++,cmake,build-essentialinstall in your Linux system...!!
这里我们假设在你的 Linux 系统中安装了g++,cmake,build-essential...!!
回答by Tonmoy
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.
cmake 2.8.12 和 Visual Studio 10 也有同样的问题。Cmake 可能找不到编译器。我通过卸载最新版本并安装了 cmake 2.8.10 解决了这个问题。
回答by wangdq
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.
在我卸载了一些 MS 软件后,我刚刚遇到了这个问题。我通过repair Visual Studio 2012 修复了它。首先进入[控制面板],然后选择visual studio 并修复它,现在一切都会好起来的。
回答by Rahul Sood
Make sure you select the proper version of visual Studio. For example, Visual Studio 2012 is version 11.
确保选择正确版本的 Visual Studio。例如,Visual Studio 2012 是版本 11。
回答by Andrey Rubshtein
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.
我遇到了同样的问题,我不得不使用"File -> Delete Cache"
,因为我不小心将 CMake 配置为使用错误的 Visual Studio 版本。
回答by Daniel Geier
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).