I am experiencing a problem when using Scons 2.3.0 in OpenSUSE:
When I added "-std=c++11" option, I saw the error
cc1plus: error: unrecognized command line option "-std=c++11"
I realized that it is because my g++ version was too old (4.1). So I upgraded it to 4.7.1. The follow thing are also done
when I try
which g++
I saw it shows the path to my new g++4.7.1
when I try g++ -v
I also saw the version 4.7.1
WITHOUT using scons, if I try to build a simple helloWorld with g++ -std=c++11 helloWorld.cpp
, everything works fine.
Now by using scons, I saw the cc1plus: error: unrecognized command line option "-std=c++11"
s.system("g++ -v")
in my SConstruct file, it still prints the right version (4.7.1)So I am not sure which part I did wrong.
Please give me some advice
Thanks in advance for the help!
SCons is choosing the older version of the compiler be default.
Doing os.system("g++ -v")
will use your PATH, but SCons internally doesnt use the PATH to find the compiler, it looks in standard locations.
If you cant uninstall the old version of the compiler, you may have to explicitly point out the new compiler. This can be done by setting some Construction Variables on the Environment as follows:
env = Environment()
env.Replace(CXX='path/g++')
env.Replace(CC='path/gcc')
You can find all the construction variables here.