Problem adding a PPA to install gcc-4.7

15,825

Solution 1

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

Solution 2

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:
15,825

Related videos on Youtube

Roman Rdgz
Author by

Roman Rdgz

Telecom Engineer

Updated on September 18, 2022

Comments

  • Roman Rdgz
    Roman Rdgz over 1 year

    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?

  • Roman Rdgz
    Roman Rdgz over 11 years
    Same results, it freezes
  • Roman Rdgz
    Roman Rdgz over 11 years
    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
  • m. öztürk
    m. öztürk over 11 years
    Sorry, I wrote a wrong path... Try the revised one...
  • Roman Rdgz
    Roman Rdgz over 11 years
    When updating I get a GPG error. I need a key. NO_PUBKEY 1E9377A2BA9EF27F
  • m. öztürk
    m. öztürk over 11 years
    Issue this command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F
  • Roman Rdgz
    Roman Rdgz over 11 years
    Well, I am able to install the packages anyway. Thanks! :)
  • Daniel
    Daniel over 4 years
    This doesn't work if there is a key error.