Ubuntu – Upgrade: solve dependency on previous release package

dependenciesdpkgpackage-management

I just upgraded from 14.04 to 16.04. This wasn't easy, probably because I had a lot of tweaks on my machine (updated packages not installed from "official" sources). It wouldn't boot, I thought at first it was a graphics card problem ("Radeon init error"), but eventually made it boot by downloading (on other machine) libstdc++6 then installing with dpkg -i, using Grub root shell
(similar problem as the one here).

I am now able to boot, have the desktop session. Fine.

Now the problem: I have a heavy package dependency problem, all the apt-get commands will fail. Consider this:

$ sudo apt-get check
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 libstdc++-5-dev : Depends: libstdc++6 (>= 5.5.0-12ubuntu1~14.04) but 5.4.0-6ubuntu1~16.04.10 is installed
 libstdc++6 : Depends: gcc-5-base (= 5.4.0-6ubuntu1~16.04.10) but 5.5.0-12ubuntu1~14.04 is installed
              Breaks: libogre-1.8.0 (<= 1.8.1+dfsg-0ubuntu5) but 1.8.1+dfsg-0ubuntu3 is installed
 libstdc++6:i386 : Depends: gcc-5-base:i386 (= 5.4.0-6ubuntu1~16.04.10) but 5.5.0-12ubuntu1~14.04 is installed
                   Breaks: libogre-1.8.0 (<= 1.8.1+dfsg-0ubuntu5) but 1.8.1+dfsg-0ubuntu3 is installed
E: Unmet dependencies. Try using -f.

The given advice (apt-get -f install) does nothing.

As you can see, what is strange is that there seems to be a mixup of packages from 14.04 and 16.04:

  • libstdc++-5-dev depends on the 14.04 version of libstdc++6, and I have of course the 16.04 version intalled.
  • libstdc++6 depends on a 16.04 package (gcc-5-base) but I seem to still have a 14.04 version!!!

I tried to reinstall the 3 packages with:

sudo apt-get -f install <pkgname> --reinstall

=> unable

I tried to remove libstdc++-5-dev with:

sudo apt-get -f remove libstdc++-5-dev

=> it asks for unmet dependencies of several other packages. If I remove them one by one, I end up at the same point.

I also tried a lot of other things but basically end up at the same point.

Other info:

$ lsb_release -ir 
Distributor ID: Ubuntu
Release:    16.04
$ uname -m
x86_64

Question: how do I get myself out of this dependency problem?

Best Answer

Problem solved, thank to this question and its answer (didn't find it at first as the title isn't very explicit, thus I don't withdraw my question, as it might be useful for others).

So, just in case, the solution is:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get -f install

(and of course after that: apt-get upgrade and apt autoremoveto finalize).

Related Question