LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 10-17-2017, 03:01 AM   #1
rydman
LQ Newbie
 
Registered: Jun 2011
Location: Malmö
Posts: 18

Rep: Reputation: Disabled
make not using developer-set version of gcc in bash


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
 
Old 10-18-2017, 03:54 AM   #2
rydman
LQ Newbie
 
Registered: Jun 2011
Location: Malmö
Posts: 18

Original Poster
Rep: Reputation: Disabled
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 set by DTS

After I updated the faulty Makefile, it works fine!

Happy days!

Richard
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to compile gcc with an older version or build gcc manually? anon002 Linux - Software 10 05-11-2015 01:05 AM
Regarding distribution + kernel version + gcc version + glib version. JCipriani Linux - General 8 04-19-2008 02:54 PM
gcc and make version shifter Programming 1 07-27-2007 04:05 AM
Making make use a specific gcc version np_ Programming 2 09-01-2005 09:08 PM
export CC=/usr/bin/gcc-3.2 - switch gcc version? ferreter Linux - Software 1 08-20-2003 12:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 06:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration