Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have both gcc 4.7.3 and 4.8.1 installed

But on running gcc --version I get

gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I am an Ubuntu newbie and I don't know much about updating symbolic-links...

I searched the Internet, and found out about update-alternatives but was reluctant to use it...

Please can someone help me in choosing 4.8 over 4.7 & also tell me is it bad to have 2 versions of same gcc?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

You need to let update-alternatives to know that you have 2 C/C++ compilers, create a record for each one, and then configure which one you want to use. This is done with the following:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
sudo update-alternatives --config gcc

From this point forward, the only thing required when switching compilers is this command:

sudo update-alternatives --config gcc

Source: http://charette.no-ip.com:81/programming/2011-12-24_GCCv47/.

share|improve this answer
    
Thank You Sir for helping :) Now whenever I type sudo update-alternatives --config gcc It presents me with 3 choices But sir Can you explain me about those priorities and status modes ?? –  sud_the_devil Jun 28 '13 at 16:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.