LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-05-2014, 09:52 AM   #1
jyunker
Member
 
Registered: Aug 2009
Posts: 167

Rep: Reputation: 0
handlling two gcc compiler on one Centos install


I have two gcc compilers on my Centos 6.5, 64 bit install. The default compiler is gcc 4.4.7 which is automatically set when I boot the system. This is standard.

I also have gcc 4.7 on my system. However, I forgot the command to make it the defualt compiler. Please tell me what it is.

Any help appreciated.

R,

jyunker
 
Old 03-05-2014, 10:12 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
The two CentOS 6 compilers are 1) gcc-4.4.7, which prowides the default
/usr/bin/gcc ( And /usr/bin/g++ , if gcc-c++ is installed.)

2) # yum install compat-gcc-34-c++ ,,, providing /usr/bin/{ gcc34 g++34 }.

All other extra compilers should be compiled with --program-suffix=<?>
.. like 46, 47, 48 for most convenience : /usr/local/gcc47/bin/gcc47 , etc.

Default compiler : I guess you can set another one (preferably temporarily)
.. with the "/etc/alternatives/" mechanism : # /usr/sbin/alternative --install <?>

-

Last edited by knudfl; 03-05-2014 at 10:16 AM.
 
Old 03-05-2014, 11:06 AM   #3
jyunker
Member
 
Registered: Aug 2009
Posts: 167

Original Poster
Rep: Reputation: 0
I want gcc 4.7 to br the default

Wait, I believe that you misunderstand me or I was not clear as to the problem. I already have both gcc 4.4.7 and gcc 4.7 on my system. I do not know where gcc 4.7 is, but I know it is on my system (it may be gcc 4.8 by now).

I just want the Centos 6.5 install to use gcc 4.7 (and all its supporting software) when I type gcc. gcc 4.7 is more advanced and its capabilities seem to fit my needs. However, I do not remmeber the command to make it the default.

That is what I am after. What is that command?

R,

jyunker
 
Old 03-05-2014, 11:55 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
# 3 .

? A gcc-4.7 package for CentOS 6 :
? Is it http://people.centos.org/tru/devtools/6/x86_64/RPMS/
→ devtoolset-1.0-gcc-4.7.0-5.3.el6.x86_64.rpm ?
(( /opt/centos/devtoolset-1.0/root/usr/bin/gcc ))

* Checking which "gcc" packages you have installed :
$ rpm -qa | grep gcc

Making an alphabetic text list with all installed packages :
$ rpm -qa | sort > installed-packages.txt

-
 
Old 03-05-2014, 12:14 PM   #5
jyunker
Member
 
Registered: Aug 2009
Posts: 167

Original Poster
Rep: Reputation: 0
Correct! make it the default

Yes that is exactly where it is.

/opt/centos/devtoolset-1.0/root/usr/bin

there is also

/opt/centos/devtoolset-1.1/root/usr/bin

Neither is in my path.

Now what command makes it the default compiler?


R,

jyunker
 
Old 03-05-2014, 12:51 PM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
# 5 .
Quote:
Now what command makes it the default compiler ?
Not something that I would recommend. EDIT : See post #7.
However I did try with the 'alternatives' command :
Setting the current gcc as 1, and "gcc 4.7" as 2 : It failed.
( May work if you move /usr/bin/gcc to <?> ).

This is easy to do : 1) cd /usr/bin/
2) # ln -s /opt/centos/devtoolset-1.1/root/usr/bin/gcc gcc47
3) # ln -s /opt/centos/devtoolset-1.1/root/usr/bin/g++ g++47
... providing /usr/bin/ { gcc47, g++47 }

Using, examples : a) $ export CC=gcc47 CXX=g++47 && ./configure
b) $ gcc47 file.c -o <executable>

-

Last edited by knudfl; 03-05-2014 at 01:36 PM.
 
Old 03-05-2014, 12:53 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,822

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
you can set up "alternatives" to do this as was posted in post #2 and #6
That is what it is for , and is recommended

or use a script to set the links
i use a script for moving between
gcc 3.4,4.3,4.7, and 4.8 (4.8 is for c++11 code)
this is an old habit of mine and CAUTION !!! must be taken
sometimes it is just much easier to use an older compiler on old code than rewrite it to use the current compiler

in /usr/bin are links
things like /usr/bin/gcc,/usr/bin/cc are a link to /usr/bin/gcc-4.3

gcc 4.8 is NOT part of Centos yet
it might be in one of the third party repos but NOT in the base repo

to see what is available
Code:
su -
yum search gcc

Last edited by John VV; 03-05-2014 at 01:05 PM.
 
1 members found this post helpful.
Old 03-05-2014, 02:48 PM   #8
jyunker
Member
 
Registered: Aug 2009
Posts: 167

Original Poster
Rep: Reputation: 0
What about what is recoomended here?

http://ask.xmodulo.com/upgrade-gcc-centos.html

When I ran that comand the following output resulted.

Code:
[james@james prefixes]$ scl enable devtoolset-1.1 bash -v
Unable to open /etc/scl/prefixes/bash!
I only got an error when I added the veerbose option.

I have a directory /etc/scl/prefies/. There is no bash sub directory.

What can I do to eliminiate the error.


Thanks.

R,

jyunker
 
Old 03-05-2014, 03:26 PM   #9
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,822

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
you could use
Code:
export CC=????????
before running ./configure
but that dose not like to work for cmake or qmake

it is better to use "alternatives"
it was made to handle this


or if you have been doing the "old school" way for years
make a script to reset the links

i could post mine
BUT !!!!!
your system WILL !! be different
you will have different compilers installed and different set of gcc tools

how many of these are installed for EACH AND EVERY version
gcc
gcc-ada
gcc-c++
gcc-fortran
gcc-gij
gcc-java
gcc-obj-c++
gcc-objc

and one of the big reasons that using a script is rather DANGEROUS
it things like kernel mods MUST build with the same version that the kernel was
-- the set default for the os version

you can run into problems very fast
this is MY version of the set to 3.4 ( old code needs this one )
Code:
#!/bin/bash

rm /usr/bin/cpp
ln -s /usr/bin/cpp-3.4 /usr/bin/cpp
echo ln -s cpp-3.4 cpp

rm /usr/bin/c++
ln -s /usr/bin/g++-3.4 /usr/bin/c++
echo ln -s cpp-3.4 cpp

rm /usr/bin/gcc
ln -s /usr/bin/gcc-3.4 /usr/bin/gcc
echo ln -s gcc-3.4 gcc

rm /usr/bin/cc
ln -s /usr/bin/gcc-3.4 /usr/bin/cc
echo ln -s gcc-3.4 cpp

rm /usr/bin/g++
ln -s /usr/bin/g++-3.4 /usr/bin/g++
echo ln -s g++-3.4 g++

rm /usr/bin/gcov
ln -s /usr/bin/gcov-3.4 /usr/bin/gcov
echo ln -s gcov-3.4 gcov
but you will have to edit it to match YOUR !!! set up

and have to MANUALLY !!!!! reset it BACK !!!!! to the system DEFAULT when you are done

Warning:
BE VERY CAREFUL !!!! VERY VERY CAREFUL!!!!!!
--- USE EXTREME CAUTION !!!!!!!----
 
  


Reply

Tags
gcc47-centos6


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to install gcc compiler mallesh Linux - Newbie 3 06-30-2011 11:22 AM
How to install gcc and g++ compiler... Carunkumar SUSE / openSUSE 3 01-03-2011 11:48 PM
how to install c compiler -gcc?? alifaziz Mandriva 3 08-22-2007 03:35 PM
why i can't install gcc or any other C compiler? HoreC Debian 3 11-21-2004 12:51 PM
GCC Compiler Install Alpha-01 Linux - Newbie 6 10-03-2004 10:48 AM


All times are GMT -5. The time now is 10:27 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration