14

I am trying to compile a project, but CMake stops right at the beginning with the message that gcc is broken (see below). I am ignoramus when it comes to CMake, so any help where to get me starting debugging this problem is very very welcome.

  • GCC (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 (I checked that my GCC compiles a 'hello world' problem)
  • CMake version 2.8.7
  • CMake command: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ../Mantid

Output to terminal:

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

It fails with the following output:

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

2 Answers 2

5

Check this link.

I had the same problem. I think the problem is that you need more parameters to compile (like linker-script, flags ...). Change your CMakeLists.txt like this and try it again:

INCLUDE(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(gcc GNU)
CMAKE_FORCE_CXX_COMPILER(g++ GNU)

Do not forget to set the path to the compiler in your environment variables.

3
  • It's not that. I found that the problem is constrained to my account. I made a new user account and I could compile from this account.
    – jmborr
    Commented May 17, 2013 at 13:08
  • Ok. so that means your last account didnt have admin-rights to access and execute the compiler?? right! Commented May 17, 2013 at 13:24
  • yes, it had. I was compiling one day with no troubles and the next day I couldn't do a thing. Go figure :( I even disabled my .bash_aliases but didn't fix the problem.
    – jmborr
    Commented May 17, 2013 at 20:27
0

Same happened with me, in CLion.

Check if your compilers and other things are properly installed and/or configured.

I Re-installed the GCC Compiler and the CMake, then reconfigured my IDE.

and it worked for me since then!

Not the answer you're looking for? Browse other questions tagged or ask your own question.