Hi!
Code:
[idae@rh69bdb scripts]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.9 (Santiago)
With this version, it's gcc 4.4 installed, but I want to code more c++11 then supported in that version.
So I have installed Red Hat Developer Toolset, that comes with 4.8 instead:
https://access.redhat.com/documentat.../chap-GCC.html
This seems to install this version alongside the current version, as it is enabled using this command:
Code:
scl enable devtoolset-2 'gcc -o output_file source_file...'
Code:
[idae@rh69bdb scripts]$ g++ -v
gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
[idae@rh69bdb scripts]$ scl enable devtoolset-2 'g++ -v'
gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)
But instead of having to type this 'scl enable devtoolset-2 ...' everytime, a new shell can be started using this devtoolset:
Code:
[idae@rh69bdb scripts]$ g++ -v
gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
[idae@rh69bdb scripts]$ scl enable devtoolset-2 'bash'
[idae@rh69bdb scripts]$ g++ -v
gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)
So far so good, now I can compile using the standard command line way, with c++11 support:
Code:
g++ -o hello hello.cpp -std=c++11
However, I build a quite large project, with many executables and libraries, so if course I use a Makefile and here is where I run into trouble. Even though I run make from a 'devtoolset-2' enabled shell, it does not invoke this version of the compiler, rather the system installed one.
Code:
[idae@rh69bdb scripts]$ g++ -v
gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)
[idae@rh69bdb scripts]$ make version
g++ -v
gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
So if just run make:
Code:
[idae@rh69bdb scripts]$ make
cc1plus: error: unrecognized command line option "-std=c++11"
And if I check, for example the PATH, it is totally different set:
Code:
[idae@rh69bdb scripts]$ echo $PATH
/opt/rh/devtoolset-2/root/usr/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/ids/bin
[idae@rh69bdb scripts]$ make version
g++ -v
gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
/usr/kerberos/sbin:/usr/kerberos/bin:/u01/app/oracle/product/12.1.0/db_1//bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
I dont really know what 'scl enable devtoolset-2' does, but the changes to the current shell doesn't seem to affect 'make'.
One solution is to add this command to everything in the Makefile, but would very much like to avoid that...
I have asked over the RHEL forums at redhat.com but haven't received any answer.
Any tips or suggestions on how to proceed?
Richard