Since upgrading from Ubuntu 16.04 to 17.04, I can no longer install gcc-7
or g++-7
from the http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu repository. In fact I cannot even install build-essential
.
Under Software & Updates > Other Software, the repository is listed like this:
http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu zesty main
Trying to install build-essential
:
$ sudo apt install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
build-essential : Depends: gcc (>= 4:5.2) but it is not going to be installed
Depends: g++ (>= 4:5.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
However:
$ gcc --version
gcc (Ubuntu 5.4.1-8ubuntu1) 5.4.1 20170304
...
$ g++ --version
g++ (Ubuntu 5.4.1-8ubuntu1) 5.4.1 20170304
...
So how can I install build-essential
again?
So I was able to install
build-essential
again by following these steps:A
gcc
version greater 5.2 is required, so lets try to installgcc
.Okay. Something else is missing. Let’s try installing that.
Still nothing. Trying again.
Once again.
So here I don’t know what exactly went wrong. It should be noted that there is a
16.04
string at the end of that version number. That seemed odd. I removed that package.Now I was able to install
build-essential
again. This will also reinstallgcc-6-base
.Remaining problem:
Root of the problem is similar as above,
gcc-7-base
is faulty but I can’t simply remove it, since I get this:Danger Zone:
I managed to resolve this issue with the following steps:
This is super dangerous and might break your installation. Executing
dpkg --force-all -P
will remove a package forcefully, ignoring any dependencies on this package. Following this by a regularapt upgrade
might remove almost all relevant software from your installation.I was only able to recover from there by usind
aptitude
which resolved every dependency issue I had.I was facing the same issue while upgrading from 14.04 LTS to 16.04 LTS. I have written the detailed solution here. But for the sake of convenience I will reproduce the key points here.
Remove all dependent libraries (
autoremove
) and install all missing libraries usingsudo apt-get -f install
(-f
means--fix-missing
)Install
ubuntu toolchain
from PPAInstall
aptitude
.Recursively try installing the broken libraries until you solve the conflict by upgrading or fixing a specific library. In my case I had to fix
libstdc++6
As
build-essential
needsgcc-5
.But
gcc-5
in turn depends oncpp-5
cpp-5
depends ongcc-5-base
. Here you can see there is a specific conflict. Aptitide gives multiple choices to solve the conflict. In my case upgrading thelibstdc++6
solvd the problem.Finally, now the conflict is resolved try installing
build-essential
again.Good Luck!
I have the same problem but the solution is actually pretty simple so it saying: The following packages have unmet dependencies:
the just install the the package on the 'depends' do :
and then it will says :
then do :
ass you can see the depends: change from depends:gcc to depends:cpp then do it over and over again until that same error didn't pop up and then :