CMake:C编译器无法编译一个简单的测试程序.令人惊讶的是,C编译器的标识是未知的,但CXX是GNU4.9.2

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.2

本文关键字:编译器 标识 未知 CXX GNU4 测试程序 编译 CMake 简单 一个      更新时间:2023-10-16

我试图编译一个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
CMakeFilescmTC_6b11a.dirbuild.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_PortableDev-CppminGW32bingcc.exe -o
CMakeFilescmTC_6b11a.dirtestCCompiler.c.obj -c
D:MichalPlikithor-v2.0-sdkbuildCMakeFilesCMakeTmptestCCompiler.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.

CMakeFilescmTC_6b11a.dirbuild.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

感谢您的帮助

如果不安装必要的构建包,则消息将出现在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

然后它工作得很好。

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

MinGW/Cxx测试异常错误

编辑:切换/更新MinGW发行版解决了所有问题。我尝试将编译器更新到7.2+/8.0+版本,并解决了所有的确认问题。很可能是一个损坏的安装程序或一些旧版本的错误