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 want to install gcc compiler 4.7 to use c++11 features. I have looked on the internet for instructions, and I found in several websites these steps:

sudo add-apt-repository ppa:Ubuntu-toolchain-r/test  
sudo apt-get update  
sudo apt-get install gcc-4.7 g++-4.7  

The problem is that my console freezes when adding the ppa.

At first I thought it was due to having an old Ubuntu version (11.04). So I have upgraded to 11.10 and then 12.04, and everything seems to work OK. But still having the same problem.

Any help?

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

The error is that you mispelled the PPA. Try this:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test  
sudo apt-get update  
sudo apt-get install gcc-4.7 g++-4.7  

If it doesn't work, create the source file manually:

sudo nano /etc/apt/sources.list.d/toolchain.list

Paste this content:

deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu precise main   
deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu precise main 

Save the file with Ctrl-K and then press Y key to confirm saving.

After adding those lines, issue this command to fix the key error:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F

Then run these commands in the terminal

sudo apt-get update
sudo apt-get install gcc-4.7 g++-4.7
share|improve this answer
    
Same results, it freezes –  Roman Rdgz Sep 27 '12 at 7:40
    
Error writing /etc/sources.list.d/toolchain.list: No such file or directory. Also tried to create the file first with sudo touch /etc/sources.list.d/toolchain.list, and says cannot touch, no such file or directory –  Roman Rdgz Sep 27 '12 at 8:05
    
Sorry, I wrote a wrong path... Try the revised one... –  Frantique Sep 27 '12 at 8:16
1  
Issue this command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F –  Frantique Sep 27 '12 at 8:24
1  
Well, I am able to install the packages anyway. Thanks! :) –  Roman Rdgz Sep 27 '12 at 8:25
show 1 more comment

As an alternate answer, you could possibly use the built-in graphic repository manager. Do this by:

Firstly,

Open the Ubuntu Software Center:

Do this by clicking on the link on your Launcher.

The Ubuntu Software Centre Icon

Or, if you have removed it from the launcher, you can search for it via the dash.

The Dash, showing Ubuntu Software Centre

Secondly,

Open the Software Sources menu:

Do this by locating the Edit menu and selecting 'Software Sources...' then once the window has opened, move to the 'Other Sources' tab.


The 'Other Software' tab.

Lastly,

Add the PPA via the window:

Below your list of current PPAs, click the 'Add' button.


The Add button


And when the window appears, enter the PPA address, which in your case is deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu precise main and deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu precise main


Add your PPA


And click 'Add Source'.


Add Source


You may also need to provide authentication by entering your user password.


Authenticate

And that's it.

Even if this doesn't work, the Software Centre may come up with a window with an error message, and most likely how to fix it. You won't believe what I went through to find a solution through the command-line and failed, and how relieved I was when I used the GUI and Ubuntu just spat the words out without me having to do anything. You may also want to combine these steps with the answer above, regarding the spelling error and such.

Cheers and good luck!

M

share|improve this answer
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.