我正在尝试编译一个项目,但 CMake 一开始就停止了,并显示 gcc 已损坏的消息(见下文)。我对 CMake 一无所知,因此非常欢迎任何帮助我开始调试此问题的帮助。
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ../Mantid
输出到终端:
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
-- Check for working C compiler: /usr/bin/gcc-4.6
-- Check for working C compiler: /usr/bin/gcc-4.6 -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
The C compiler "/usr/bin/gcc-4.6" is not able to compile a simple testprogram.
它失败并显示以下输出:
Change Dir: /home/jmborr/devel/mantidproject/mantid/Code/debug/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build
make[1]: Entering directory `/home/jmborr/devel/mantidproject/mantid/Code/debug/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/jmborr/devel/mantidproject/mantid/Code/debug/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o
/usr/bin/gcc-4.6 /usr/include -o CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -c /home/jmborr/devel/mantidproject/mantid/Code/debug/CMakeFiles/CMakeTmp/testCCompiler.c
gcc-4.6: warning: /usr/include: linker input file unused because linking not done
Linking C executable cmTryCompileExec
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1
/usr/bin/gcc-4.6 /usr/include /usr/lib CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -o cmTryCompileExec -rdynamic
/usr/bin/ld: cannot find /usr/include: File format not recognized
/usr/bin/ld: cannot find /usr/lib: File format not recognized
collect2: ld returned 1 exit status
make[1]: Leaving directory
最佳答案
检查这个 link .
我有同样的问题。我认为问题是你需要更多的参数来编译(比如链接器脚本、标志......)。像这样更改您的 CMakeLists.txt 并重试:
INCLUDE(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(gcc GNU)
CMAKE_FORCE_CXX_COMPILER(g++ GNU)
不要忘记在环境变量中设置编译器的路径。
关于gcc - CMake 报告 GCC 已损坏。我从哪里开始?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16594053/