Search code examples
compiler-errorscmakecompiler-flags

Cmake errors of installing ccons


After I execute cmake CMakeLists.txt, which seems to give no errors, I run make which gives me the following error:

:/usr/local/src/llvm-3.1.src/tools/ccons$ sudo make
[  7%] Building CXX object CMakeFiles/ccons.dir/ccons.cpp.o
/usr/local/src/llvm-3.1.src/tools/ccons/ccons.cpp:1:0: error: bad value (x86_64) for -march= swi
tch
make[2]: *** [CMakeFiles/ccons.dir/ccons.cpp.o] Error 1
make[1]: *** [CMakeFiles/ccons.dir/all] Error 2
make: *** [all] Error 2

Is there any way to figure out how to solve this?


Solution

  • Firstly, why are you building the software using sudo? That's asking for trouble. You should only need sudo when you're installing (i.e., sudo make install).

    For whatever reason, your compiler appears to be passed the flag -march=x86_64, which it thinks is invalid. To see what flags CMake is trying to compile with, do the following:

    1. Run make edit_cache.
    2. Press t to switch on advanced mode. This lets you see additional cache variables.
    3. Look for the variables that start with CMAKE_CXX_FLAGS. There are different ones for different build types, but one of them will probably have this -march=x64_64 flag in it.

    Good luck.