Since trying to upgrade to 16.04 xenial, I'm getting

$ apt
apt: relocation error: /usr/lib/x86_64-linux-gnu/libapt-pkg.so.5.0: 
symbol _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareERKS4_, 
version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference

when simply running apt. Needless to say this makes it difficult to do anything.

Any hints?

  • wow … this makes me really distrust Ubuntu/Canonical’s upgrade process. Every time I have a working but stale version, someone in a help forum tells me upgrades will solve all my problems…I don’t know what a "scratch disk" is, and certainly don’t want to have to interrupt work with GRUB debugging… – isomorphismes Jul 28 '17 at 14:30

11 Answers 11

I had the same problem caused by issues from PPA for Ubuntu toolchain. My computer would not boot because of it. Following @w00kie's comment on his answer, I downloaded (from tty terminal) the debian of package libstdc++6 for Xenial at link http://packages.ubuntu.com/xenial/libstdc++6 and installed using dpkg -i. The computer works just fine now.

  • 4
    Can you please put the commands, step by step in your answer? I'm not familiar with this at all and my linux machine is horked... – Zachary Fields Jul 20 '16 at 7:58
  • @Zachary What is the exact issue you're facing? Are you able to boot? – Sagar Jha Jul 20 '16 at 13:14
  • 1
    Not really. If I let it go the screen flickers for about 15 mins, then I get a tty2 terminal prompt in a very light grey color. I'm unable to use apt (or any tool really). I have even tried to download libstdc++6...deb from a bootable USB drive, manually place the package, reboot into the broken system and installing the .deb using sudo dpkg -i libstdc++6...deb, but it doesn't even know what dpkg is. – Zachary Fields Jul 20 '16 at 17:04
  • 12
    To download/install the .deb file, you can do: wget http://security.ubuntu.com/ubuntu/pool/main/g/gcc-5/libstdc++6_5.4.0-6ubuntu1~16.04.2_amd64.deb and then once that downloads, dpkg -i libstdc++6_5.4.0-6ubuntu1~16.04.2_amd64.deb (assumes 64-bit system). For me, my internet connection wasn't working, so I downloaded it onto a USB drive from a different computer, then had to manually mount the USB drive on my problematic computer (sudo mount /dev/sdc1 /media/usb where sdc1 was found by watching terminal output right after plugging in USB ) and then run the above dpkg command. – Garrett Aug 25 '16 at 4:25
  • 5
    I had to use dpkg --force-all -i libstdc+‌​+6_5.4.0-6ubuntu1~16‌​.04.2_amd64.deb to get it installed – virtualxtc Jul 26 '17 at 5:49
up vote 22 down vote accepted

The culprit are left-overs from the PPA for Ubuntu Toolchain Uploads (restricted), specifically

/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22

There are two possibilities of dealing with this:

  • You already have ppa-purge installed. Then

    sudo ppa-purge ppa:ubuntu-toolchain-r/test
    

    fixes the issues.

  • Override the libstc++ by downloading libstdc++6 for Xenial and installing it via dpkg -i.

  • 4
    At least for me, this fails with message identical to the one in the question... – mbdevpl Jun 26 '16 at 12:10
  • 1
    Should probably be expanded with answers from below, because obviously ppa-purge won't work (same python) – user64204 Jun 30 '16 at 21:34
  • 1
    I get: sudo: ppa-purge: command not found – Garrett Aug 25 '16 at 3:41
  • @Garrett sudo apt install ppa-purge – Nico Schlömer Aug 25 '16 at 15:04
  • 2
    @NicoSchlömer, thanks, but actually, I believe my apt was also not working (as per the original post). – Garrett Aug 25 '16 at 23:57

My comp failed to boot correctly because of this error. Apt-get was not working, nor was Gnome. This was immediatelly after an upgrade from 14.04 to 16.04. I solved it in tty by entering

sudo apt-add-repository --remove ppa:ubuntu-toolchain-r/test

At this point apt-get started to work again and I was able to fix all isues from there:

sudo apt-get clean
sudo apt-get update
sudo apt-get install -f
sudo dpkg -a --configure
sudo apt-get dist-upgrade

I also had to uninstall Virtualbox (after the update command) and reinstal it later, but I think this was unrelated.

  • 2
    i tried this but got an import error on package apt_pkg – Mixone Aug 21 '16 at 8:17
  • Mixone, what was the exact error and on which command exactly? – Matjaz Aug 23 '16 at 10:22
  • sudo apt-get update the error came from the python backend i guess, the stacktrace was python and it basically said cannot find module apt_pkg – Mixone Aug 24 '16 at 7:49
  • 5
    Same problem for me too, trying to use the apt-add-repository command in your answer gives: ImportError: /usr/lib/x86_64-linux-gnu/libapt-pkg.so.5.0: symbol _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareERKS4_, version GLIBCXX_3.4.21 not defined in the file libstdc++.so.6 with link time reference – Garrett Aug 25 '16 at 4:10
  • For idiots like me trying to upgrade 2 years after the release and thinking all the bugs are fixed. Link in the comment above is broken. Here is the new one. http://security.ubuntu.com/ubuntu/pool/main/g/gcc-5/libstdc++6_5.4.0-6ubuntu1~16.04.10_amd64.deb (or i386 or both) And don't mind dpkg cursing you. Do --auto--deconfigure and your apt-get will be back on track afterwards despite error messages. And you will be able to finish with proper -f --install + --upgrade and reboot into a fresh system. – Ufos Jul 1 at 23:21

I had been thinking the problem was something unique to me, and was caused by a download error.

This discussion gave me the clue I needed. Basically, all that was needed was to replace libstdc++.so.6.0.22 with libstdc++.so.6.0.21 in /usr/lib/x86_64-linux-gnu of the failing system. (It seems there's an error in the newer version.)

This can be done from a thumb-drive or, as in my case, from a scratch disk.

Full details at: https://answers.launchpad.net/ubuntu/+question/395832

Thanks to all...

  • I used this trick, but did a dual boot on some spare space. I was able to easily mount the original partition. It was pretty easy. – Andrew Sep 22 '16 at 0:53
  • Awesome - these 3 commands worked for me: cd /usr/lib/x86_64-linux-gnu/ >>> sudo rm libstdc++.so.6 >>> sudo ln -s libstdc++.so.6.0.21 libstdc++.so.6 – osman May 17 '17 at 18:20

Following the dpkg -i approach in the accepted answer, my 14.04->16.04 upgrade required not one but two packages:

gcc-5-base_5.4.0-6ubuntu1~16.04.4_i386.deb
libstdc++6_5.4.0-6ubuntu1~16.04.4_i386.deb

After this, apt upgrade was able to download the remaining packages and complete the installation.

If you have the latest version of the 'conjure-up' snap installed with Snappy on Yakkety, your apt will be broken with a very similar error:

apt: relocation error: /usr/lib/x86_64-linux-gnu/libapt-private.so.0.0: symbol _ZN13pkgSourceList16AddVolatileFilesER11CommandLinePSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EE, version APTPKG_5.0 not defined in file libapt-pkg.so.5.0 with link time reference

due to this bug:

https://bugs.launchpad.net/snappy/+bug/1a677417

Currently the only workaround I know of is the remove the conjure-up snap (or possibly 'snap revert' it to a previous version if you had one installed prior).

You should be able to fix it by typing:

sudo apt-get -f install

without specifing any package. It should do the work.

There can be a very similar problem with i386 systems.

To solve the problem, I also had to downgrade gcc-5-base from Version 5.4.1-2ubuntu1~12.04 to 5.4.0-6ubuntu1~16.04.4.

To complete the upgrade to a reasonable-seeming system, I also had to use dpkg --purge on vituoso_nepomuk and virtualbox to get rid of their configuration files, which were causing trouble (for me, VirtualBox is provided by package virtualbox-5.1, which seems unscathed by the upgrade.)

The key was to get dpkg --configure dbus to work.

To enable wget while in a tty-type screen, users may also need to execute sudo dhclient eth0 to enable a wired ethernet connection.

The fix that worked for me was to actually add the Ubuntu toolchain ppa back:

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

I've just had this problem when upgrading ubuntu distribution on linux I saw that:

# ls /usr/lib/x86_64-linux-gnu/libstdc++.so.6*
libstdc++.so.6 -> libstdc++.so.6cd*
libstdc++.so.6.0.20*
libstdc++.so.6.0.21
libstdc++.so.6cd -> libstdc++.so.6.0.20*

libstdc++.so.6 -> libstdc++.so.6cd -> libstdc++.so.6.0.20

But there were two files: libstdc++.so.6.0.21 and libstdc++.so.6.0.20

I've changed the symbolic link to point to latest version libstdc++.so.6.0.21

cd /usr/lib/x86_64-linux-gnu
rm libstdc++.so.6cd
chmod +x libstdc++.so.6.0.21
ln -s  libstdc++.so.6.0.21 libstdc++.so.6cd

Resulting:

libstdc++.so.6 -> libstdc++.so.6cd*
libstdc++.so.6.0.20*
libstdc++.so.6.0.21*
libstdc++.so.6cd -> libstdc++.so.6.0.21*

and everything came back to normal

  1. Download libstdc++6 for your ubuntu from Ubuntu package manager website. ( use uname -a to find the h/w and s/w architecture).

  2. Run

    sudo dpkg --install --auto-deconfigure libstdc++6...deb
    
  3. Reboot. Ubuntu should boot but apt would not install new packages.

  4. To fix dependencies and make system up to date, run these commands

    sudo apt-add-repository ppa:ubuntu-toolchain-r/test
    sudo apt-get update
    sudo apt-get install -f
    sudo apt-get upgrade
    sudo apt-get dist-upgrade
    sudo apt-get autoclean && sudo apt-get autoremove  
    

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.