gcc - CMake 报告 GCC 已损坏。我从哪里开始?

标签 gcc cmake

我正在尝试编译一个项目,但 CMake 一开始就停止了,并显示 gcc 已损坏的消息(见下文)。我对 CMake 一无所知,因此非常欢迎任何帮助我开始调试此问题的帮助。

  • GCC (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 (我检查了我的 GCC 是否编译了一个“hello world”问题)
  • CMake 版本 2.8.7
  • 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/

    相关文章:

    c++ - 使用 Cmake 在 Mac 上的 VTK 配置问题

    c - 如何将具有多个源子目录的 Make 和 Autotools 项目迁移到 CMake?

    c++ - C++11 中的线程安全单例

    java - 编译器使用关联性有什么问题?

    gcc - SSE 4 popcount 为 16 个 8 位值?

    gcc - 当一个人输入错误时,编译器如何猜测正确的名字?

    android - 'imported-lib - NOTFOUND' 在为 android studio 2.2 构建 ffmpeg 3.2

    CMake如何将构建目录设置为与源目录不同

    c++ - Opencv 链接 CMAKE 不工作 Ubuntu 16.04 Docker

    c - 合并多个 .so 共享库