【问题标题】:CMake: The C compiler is not able to compile a simple test program. Surprisingly C compiler identification is unknown but CXX is GNU 4.9.2CMake:C 编译器无法编译简单的测试程序。令人惊讶的是,C 编译器标识未知,但 CXX 是 GNU 4.9.2
【发布时间】:2016-08-03 11:03:28
【问题描述】:

我试图编译一个 Thor 库。这取决于 SFML。我在编译也依赖于 SFML 的 SFGUI 时没有任何问题。以前我使用完全相同的工具链。一切正常

CMake gui 错误:

The C compiler identification is unknown
The CXX compiler identification is GNU 4.9.2
Check for working C compiler: E:/Programs_Portable/Dev-Cpp/minGW32/bin/gcc.exe
Check for working C compiler: E:/Programs_Portable/Dev-Cpp/minGW32/bin/gcc.exe -- broken
CMake Error at C:/CMake/share/cmake-3.4/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "E:/Programs_Portable/Dev-Cpp/minGW32/bin/gcc.exe" is not able to compile a simple test program.

It fails with the following output:

Change Dir: D:/Michal/Pliki/thor-v2.0-sdk/build/CMakeFiles/CMakeTmp



Run Build
Command:"E:/Programs_Portable/Dev-Cpp/minGW32/bin/mingw32-make.exe"
"cmTC_6b11a/fast"

E:/Programs_Portable/Dev-Cpp/minGW32/bin/mingw32-make.exe -f
CMakeFiles\cmTC_6b11a.dir\build.make CMakeFiles/cmTC_6b11a.dir/build


mingw32-make.exe[1]: Entering directory
'D:/Michal/Pliki/thor-v2.0-sdk/build/CMakeFiles/CMakeTmp'


Building C object CMakeFiles/cmTC_6b11a.dir/testCCompiler.c.obj


E:\Programs_Portable\Dev-Cpp\minGW32\bin\gcc.exe -o
CMakeFiles\cmTC_6b11a.dir\testCCompiler.c.obj -c
D:\Michal\Pliki\thor-v2.0-sdk\build\CMakeFiles\CMakeTmp\testCCompiler.c


<built-in>: internal compiler error: Segmentation fault


libbacktrace could not find executable to open


Please submit a full bug report,


with preprocessed source if appropriate.


See <http://sourceforge.net/projects/mingw-w64> for instructions.


CMakeFiles\cmTC_6b11a.dir\build.make:64: recipe for target
'CMakeFiles/cmTC_6b11a.dir/testCCompiler.c.obj' failed


mingw32-make.exe[1]: *** [CMakeFiles/cmTC_6b11a.dir/testCCompiler.c.obj]
Error 1


mingw32-make.exe[1]: Leaving directory
'D:/Michal/Pliki/thor-v2.0-sdk/build/CMakeFiles/CMakeTmp'


makefile:125: recipe for target 'cmTC_6b11a/fast' failed


mingw32-make.exe: *** [cmTC_6b11a/fast] Error 2






CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:42 (project)


Configuring incomplete, errors occurred!
See also "D:/Michal/Pliki/thor-v2.0-sdk/build/CMakeFiles/CMakeOutput.log".
See also "D:/Michal/Pliki/thor-v2.0-sdk/build/CMakeFiles/CMakeError.log".

我尝试编译简单的int main(){}。 gcc 有效。 所有路径都符合预期。 (顺便说一句,我不使用 DevCpp,它只是编译器的路径)。

我很惊讶,因为 g++ 有效,CMake 能够显示标识但显然不适用于 gcc

感谢您的帮助

【问题讨论】:

  • 错误消息的哪一部分“请提交完整的错误报告,如果合适,请提供预处理的源代码。有关说明,请参阅 sourceforge.net/projects/mingw-w64>。”你听不懂?
  • 我已经很久没有编译器段错误了。我更感兴趣的是为什么会发生这种情况以及为什么 CMake 无法识别身份
  • 为什么?因为您发现了一个编译器错误。如果计算机可以找出自己的错误,他们将能够自己修复所有错误。我们还没有达到这种技术状态。
  • 所以?没有法律规定你不能乱用别人的代码。试试吧。你没有什么可失去的,而且你可能真的学到了一些东西。
  • 所以尝试手动编译相同的程序。 CMake 构建日志为此包含确切的命令行:它位于行 &lt;built-in&gt;: internal compiler error 之前。从构建目录运行此命令行( D:\Michal\Pliki\thor-v2.0-sdk\build\ 在你的情况下)。

标签: c++ cmake mingw


【解决方案1】:

如果您未安装必要的构建包,Solus OS 上会显示该消息。

CMake Error at /usr/share/cmake-3.12/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler

   "/usr/bin/cc"

is not able to compile a simple test program.

你必须安装包,使用

sudo eopkg it -c system.devel

然后它就可以正常工作了。

【讨论】:

  • 切换/更新 MinGW 发行版解决了所有问题。我更新了编译器并摆脱了所有配置问题。可能是安装损坏或一些较旧的 vrsion 错误。
【解决方案2】:

现在通过将我的 GCC 从 4.9.2 升级到 4.9.3 来修复。没有更多的崩溃问题,但显然有一个与 C++11 标准相关的更改,我需要在编译任何库和任何程序时手动编辑 CMakeLists.txt 以将标志 -std=c++11 更改为 -std=gnu++11

MinGW / CxxTest bizarre errors

编辑:切换/更新 MinGW 发行版解决了所有问题。我尝试将编译器更新到 7.2+/8.0+ 版本并摆脱了所有配置问题。可能是安装损坏或某些旧版本错误

【讨论】:

    猜你喜欢
    • 2019-05-07
    • 2014-01-05
    • 1970-01-01
    • 2022-07-12
    • 2016-03-04
    • 2021-01-23
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    相关资源
    最近更新 更多