Ubuntu – Problem adding a PPA to install gcc-4.7

gccppasoftware installation

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.

How to fix this issue?

Best Answer

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
Related Question