Running devtool-set version of g++ from Makefile

Latest response

Good morning!

I just installed devtools-2 as I need better c++11 support in our project. Everything works fine, but I can't figure out how I use this version when compiling using a Makefile, as it then seems to fallback and using version 4.4

[idd@rh67bda scripts]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.9 (Santiago)
[idd@rh67bda ~]$ g++ -v
gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
[idd@rh67bda ~]$ scl enable devtoolset-2 'bash'
[idd@rh67bda ~]$ g++ -v
gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)
[idd@rh67bda scripts]$ make version
g++ -v
gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
[idd@rh67bda scripts]$

Running this doesn't seem to work either, as 4.8 understands c++11:

[idd@rh67bda scripts]$ scl enable devtoolset-2 'make'
cc1plus: error: unrecognized command line option "-std=c++11"

Maybe not a devtool issue per se, perhaps more a bash/make problem, but any help would be greatly appreciated

Regards
Richard

Responses

Hi Richard,

I'm not sure why the DTS version of make isn't working for you. I just tried it on a fresh install, and it works with the scl commands you used. (Also, I'm unsure what the make version command means -- do you have a target named version in your Makefile?)

Anyway, is there any reason for you to use DTS 2? The current version of DTS is 6.1, which provides significantly newer versions of all components, including GCC and Make. DTS 6.1 is also compatible with RHEL 6.9, which you use, so you shouldn't have any problems installing it. See Installing Red Hat Developer Toolset in the DTS 6.1 User Guide.

Thanks for your reply!

First, yes, 'make version' is just a target added by me in the Makefile when I saw it didn't work to see what version make was using:

version:
        g++ -v

I also did some other tests, for example checking the $PATH variablewhen in the 'normal scl enabled shell' and the one used by make (added echo $PATH to "make version" in Makefile):

[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

First path clearly shows paths added to the dts version of gcc. But this is not the path at all used when invoking make.

And the reason for sticking with version 2 of dts, is we only need and cant go any further then version 4.8 of gcc.

Richard

Good morning!

When it's working for you, does DTS use the installed system version of make, as it does for me:

[ids@rh67bd ~]$ which make
/usr/bin/make
[idae@rh69bdb ~]$ scl enable devtoolset-2 'bash'
[idae@rh69bdb ~]$ which make
/usr/bin/make
[idae@rh69bdb ~]$

Or does it use a version installed with DTS?

Regards Richard

Hi again!

Think I have solved it.

This PATH issue lead me to investigate the Makefiles, we have alot of them, nested etc etc

And in one of them, we actually changed this environment variable, not including this new path.

After I updated the faulty Makefile, it works fine!

Happy days!

Richard

Glad to hear that. Thanks for sharing, Richard.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.