Reputation: 497
I am trying to build something that requires CMake, however when I try:
cmake -DBUILD_EXAMPLES=YES -DBUILD_TESTS=YES
I get the error:
Your systems default compiler is GCC. This project makes use of c++11
features present only in versions of gcc >= 4.9. You can use a different
compiler by re-running cmake with the command switch "-D
CMAKE_CXX_COMPILER=<compiler>"
I have tried using CMAKE_CXX_COMPILER=c++11
and CMAKE_CXX_COMPILER=g++11
but those get errors too. Is this because I am using the wrong variable or because I don't have c++11 installed? What would be the fix for it?
Upvotes: 1
Views: 981
Reputation: 54737
It looks like your compiler is too old. Be sure to check the output of gcc -v
.
If you don't want to replace your system's default compiler, you can specify an alternative compiler on the command line as follows:
CXX=g++49 CC=gcc49 cmake -DBUILD_EXAMPLES=YES -DBUILD_TESTS=YES <path_to_source>
Where g++49
and gcc49
are the names of the alternative compiler on your system.
Most Linux distributions allow installing more than one version of gcc at the same time, so you should be able to achieve this without too much of a hassle.
Upvotes: 3