How to fix broken libstdc++6, which also breaks apt
At first, I was able to get a graphical login shell by manually copying libstdc++.so.6.0.21
into its place from a Live USB stick, and creating a link to it from libstdc++.so.6
. I used this exact version because it seems to be the default for Ubuntu 16.04 and also contains the "21" mentioned in the error message ("version GLIBCXX_3.4.21").
While this seemed to satisfy the graphics stack, the same errors remained with apt
and other programs depending on libstdc++6. After some trying, I could resolve the whole thing with the following steps, using dpkg
to manually (un)install things:
-
Download the deb files in the right versions for 16.04:
wget http://mirrors.kernel.org/ubuntu/pool/main/a/apt/apt_1.2.10ubuntu1_amd64.deb http://mirrors.kernel.org/ubuntu/pool/main/g/gcc-5/libstdc++6_5.4.0-6ubuntu1~16.04.4_amd64.deb
-
Removing this specific version, which blocked installing the correct libstdc++6:
sudo dpkg --force-depends -r libstdc++6:i386
-
Then install the "good" version from the files:
sudo dpkg -i libstdc++6_5.4.0-6ubuntu1~16.04.4_amd64.deb apt_1.2.10ubuntu1_amd64.deb
-
And finally, fix the mess I left while updating and trying things out:
sudo apt-get install -f
Related videos on Youtube
phipsgabler
I started by teaching myself C#, then I learned Python as a second language. During that, I began with Haskell and some Agda and fell in love with functional programming. At university, I used Scala and Python a lot. Lately, I began to do much stuff in Julia.
Updated on September 18, 2022Comments
-
phipsgabler over 1 year
I seem to have messed up something with a manual
gcc
update sometime in the past, which didn't become a problem until today, when I upgraded from 14.04 to 16.04. Namely, the system seems to think that thelibstdc++6
version is OK, whileapt
(and many other programs) complain it isn't (because the shared library is actually in the wrong version):sudo apt-get install --fix-broken --fix-missing apt-get: 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
The system doesn't even start a graphical mode, the above output was obtained using a non-graphical console (using
Ctrl-Alt-F6
), andapt
itself is completely unusable, so I can't just do something like a reinstall.How can I fix and reinstall these packages, when the program I'm using for managing them itself is affected and unusable?
-
Ugo almost 6 yearsSaved my life !
-
plonknimbuzz over 5 yearsfor 32bit.
wget http://mirrors.edge.kernel.org/ubuntu/pool/main/a/apt/apt_1.2.10ubuntu1_i386.deb http://security.ubuntu.com/ubuntu/pool/main/g/gcc-5/libstdc++6_5.4.0-6ubuntu1~16.04.10_i386.deb
thensudo dpkg --force-depends -r libstdc++6:i386
thensudo dpkg -i libstdc++6_5.4.0-6ubuntu1~16.04.10_i386.deb apt_1.2.10ubuntu1_i386.deb
-
mvladk over 5 yearsFor Ubuntu 18.04.1 packages.ubuntu.com/bionic/amd64/libstdc++6/download had similar problem: sudo apt-get update apt-get: error while loading shared libraries: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: invalid ELF header