我们在使用 Visual Studio 2012 在 Windows 7 64 位下使用 CMake (v2.8.12) 编译项目时遇到问题。CMake 给我们提供了以下错误。我们已经尝试使用管理员权限从 Visual Studio 命令行启动 Cmake。 CMake 2.8.11 中似乎也存在类似的错误:http://www.cmake.org/Bug/view.php?id=14440 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
并检查那里的错误消息以查看:
- CMake 使用了哪个编译器路径/命令行
-
调用编译器的错误消息是什么
e.g. LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'
如果你添加--debug-trycompile
to the 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 https://developer.microsoft.com/en-us/windows/downloads/windows-8-1-sdk(因为 Visual Studio 2012 确实以 Windows 8.x 为目标),瞧我的 CMake 能够再次编译(测试)程序。
参考
- Visual Studio 2012 是否包含完整的 Windows SDK https://stackoverflow.com/questions/12014963/does-visual-studio-2012-include-the-full-windows-sdk
- CMakeLists.txt 处的 CMake 错误:30(项目):找不到 CMAKE_C_COMPILER https://stackoverflow.com/questions/32801638/cmake-error-at-cmakelists-txt30-project-no-cmake-c-compiler-could-be-found
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)