Ubuntu – Cannot install gcc-4.8 because of unmet dependencies

13.10dependenciesgccinstallationppa

I was trying to upgrade gcc-4.8.1 to gcc-4.8.2 using Synaptic from this PPA. The installation executed with no problem, but suddenly I had no gcc-4.8 at all. I was using gcc-4.7 and gcc-4.8 together, but only 4.7 is left for some reason. Then I tried to reinstall gcc-4.8 using apt-get install but I got unmet dependencies errors. I tried to solve this problem using the answers to this question, but to no avail.

sudo apt-get install gcc-4.8

results in:

...
The following packages have unmet dependencies:
 gcc-4.8 : Depends: binutils (>= 2.23.90.20131017) but
2.23.52.20130913-0ubuntu1 is to be installed
E: Unable to correct problems, you have held broken packages.

Here are the outputs of:

martin@martin-Studio-1537:~$ cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu saucy main universe restricted multiverse
deb http://security.ubuntu.com/ubuntu/ saucy-security main universe restricted multiverse
deb http://archive.ubuntu.com/ubuntu saucy-updates main universe restricted multiverse
deb http://archive.ubuntu.com/ubuntu saucy-proposed main universe restricted multiverse
deb-src http://archive.ubuntu.com/ubuntu saucy main universe restricted multiverse #Added by software-properties
deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu saucy main

and

martin@martin-Studio-1537:~$ cat /etc/apt/sources.list.d/*
# deb http://download.mendeley.com/apt/ stable main
deb http://ppa.launchpad.net/p12/qtcreator/ubuntu saucy main
deb-src http://ppa.launchpad.net/p12/qtcreator/ubuntu saucy main
deb http://ppa.launchpad.net/p12/qtcreator/ubuntu saucy main
# deb-src http://ppa.launchpad.net/p12/qtcreator/ubuntu saucy main
deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu saucy main
deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu saucy main
# deb http://ppa.launchpad.net/webupd8team/y-ppa-manager/ubuntu saucy main
# deb-src http://ppa.launchpad.net/webupd8team/y-ppa-manager/ubuntu saucy main
# deb http://ppa.launchpad.net/webupd8team/y-ppa-manager/ubuntu saucy main
# deb-src http://ppa.launchpad.net/webupd8team/y-ppa-manager/ubuntu saucy main

I tried to repeat the suggestions in the answers after disabling all PPAs and then again with the gcc-4.8.2 PPA enabled and I still cannot install gcc-4.8.2.

What did I do wrong and how can I fix my system?

EDIT:

I tried

martin@martin-Studio-1537:~$ sudo apt-get install -f
[sudo] password for martin: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

and then

sudo apt-get update

but the result is the same.

I tried everything in this answer with the exception of purging or removing PPAs.

EDIT2:

I followed instructions from searchforgold6789's answer and it did work! I successfully installed gcc-4.8.1. But when I added the PPA again and tried to upgrade, I got the following output:

The following packages have been kept back:
  cpp-4.8 g++-4.8 gcc-4.8 gcc-4.8-base libasan0 libatomic1 libgcc-4.8-dev
  libgcc1 libgcc1-dbg libgfortran3 libgomp1 libitm1 libquadmath0
  libstdc++-4.8-dev libstdc++6 libstdc++6-4.8-dbg
The following packages will be upgraded:
  libcloog-isl4 libisl10
2 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.

EDIT3:

When I do a apt-get dist-upgrade it suggests that g++-4.8 gcc-4.8 should be removed. Why is this so? Should I proceed? I think this was the reason I got into this trouble in the first place.

martin@martin-Studio-1537:~$ sudo apt-get dist-upgrade
...
The following packages will be REMOVED:
  g++-4.8 gcc-4.8
The following packages will be upgraded:
  cpp-4.8 gcc-4.8-base libasan0 libatomic1 libgcc-4.8-dev libgcc1 libgcc1-dbg
  libgfortran3 libgomp1 libitm1 libquadmath0 libstdc++-4.8-dev libstdc++6
  libstdc++6-4.8-dbg
14 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
Need to get 14.9 MB of archives.
After this operation, 32.4 MB disk space will be freed.

Best Answer

First you should clean up the old ppa...

sudo apt-get install ppa-purge 
sudo ppa-purge ppa:ubuntu-toolchain-r/test

Then, go into Software Sources and make sure you have the universe and multiverse repositories enabled. Do:

sudo apt-get update

Then you should be able to install gcc-4.8:

sudo apt-get install gcc-4.8

After that, I would be highly surprised if you could not add the PPA and try again with GCC 4.8.2, successfully.

Related Question