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.

Andrew
  • 11
  • 1
  • 2
  • 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 07 '18 at 09:49
  • If I put into an ubuntu fs, how can it fix a raspbian jessie fs? – Andrew Apr 07 '18 at 09: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 07 '18 at 09: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 07 '18 at 10:55
  • please add the missing part before the error, your cli input – Fabian Apr 07 '18 at 11:07

1 Answers1

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.

Aurora0001
  • 6,308
  • 3
  • 23
  • 38
  • Are you able to provide me the libstdc++.so.6 with support for GLIBCXX_3.4.21? Thank you. – Andrew Apr 07 '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 07 '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 07 '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 07 '18 at 10:27
  • Linux ::Hostname:: 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux – Andrew Apr 07 '18 at 10:28
  • 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 07 '18 at 10:38