Problem adding a PPA to install gcc-4.7
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.
Or, if you have removed it from the launcher, you can search for it via the dash.
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.
Lastly,
Add the PPA via the window:
Below your list of current PPAs, click 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
And click 'Add Source'.
You may also need to provide authentication by entering your user password.
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
Related videos on Youtube
Comments
-
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 over 11 yearsSame results, it freezes
-
Roman Rdgz over 11 yearsError 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 over 11 yearsSorry, I wrote a wrong path... Try the revised one...
-
Roman Rdgz over 11 yearsWhen updating I get a GPG error. I need a key. NO_PUBKEY 1E9377A2BA9EF27F
-
m. öztürk over 11 yearsIssue this command:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F
-
Roman Rdgz over 11 yearsWell, I am able to install the packages anyway. Thanks! :)
-
Daniel over 4 yearsThis doesn't work if there is a key error.