1

I have a raspberry pi 3 mounting Retropie (jessie version). This is the situation:

   libstdc++.so.6: symbolic link to libstdc++.so.6.0.21

apt-get: error while loading shared libraries: libstdc++.so.6: wrong ELF class: ELFCLASS64

I can't use apt-get to install anything. What should I do? I have:

gcc (Raspbian 4.9.2-10+deb8u1) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This is really frustrating since I have a lot of things working on my rpi. I've been looking around a solution to find the right libstdc++.so.6 and tried plenty of them.

  • How did it get into that state? Try plugging the SD card into another machine to check and repair the file-system. – John Hawthorne Apr 7 '18 at 9:49
  • If I put into an ubuntu fs, how can it fix a raspbian jessie fs? – Andrew Apr 7 '18 at 9:51
  • Open a terminal in ubuntu, and use this command but instead of using sdc2, use the correct name for the ext4 partition on your SD card: sudo e2fsck -f /dev/sdc2 – John Hawthorne Apr 7 '18 at 9:53
  • I do not understand why only apt-get complains this error. What about other programs using libstdc++.so.6? And what has it to do with gcc? – Ingo Apr 7 '18 at 10:55
  • please add the missing part before the error, your cli input – Fabian Apr 7 '18 at 11:07
1

ELFCLASS64 suggests you have a 64-bit version of libstdc++.so.6 somehow. If you tried to replace it manually with a different version you found somewhere else, that's probably the cause of the error. Generally, replacing system shared objects is unwise as you never know what depends on them.

If you are unable to replace libstdc++.so.6 with the correct version for your operating system (Raspbian is still 32-bit as far as I'm aware), you will probably need to start with a clean image.

libstdc++6 version 4.9.2 in the repositories is available here if you wish to attempt to extract it and replace the .so file with the appropriate version. Note that you need to copy both libstdc++.so.6.0.20 and libstdc++.so.6 for this to work properly. This is at your own risk however; if you have valuable files, save them before doing anything further.

| improve this answer | |
  • Are you able to provide me the libstdc++.so.6 with support for GLIBCXX_3.4.21? Thank you. – Andrew Apr 7 '18 at 10:04
  • Does the one I linked to not work, @Andrew? That is the one provided in the repositories for Jessie; I haven't checked what it's compatible with but it should at least fix your system issues. – Aurora0001 Apr 7 '18 at 10:11
  • It works, but apt-get says:apt-get: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by apt-get). I think we're looking for a different gcc here. – Andrew Apr 7 '18 at 10:12
  • Could you double check exactly which version of Raspbian you're running with uname -a? Just post the entire output here. – Aurora0001 Apr 7 '18 at 10:27
  • 1
    It's odd that using the system-provided package doesn't work; personally I'd suggest just cutting your losses at this point and starting with a fresh image - that's often easier than trying to patch up a broken system. – Aurora0001 Apr 7 '18 at 10:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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