7

I am using Ubuntu 12.04.3 LTS, 64-bit, with gcc 4.6.3

I want to update gcc to 4.7, and do as the link said:

How do I install gcc 4.7?

But I got error:

Fetched 14.0 MB in 18s (767 kB/s)                                    
(Reading database ... 205536 files and directories currently installed.)
Preparing to replace libgcc1 1:4.6.3-1ubuntu5 (using .../libgcc1_1%3a4.8.1-2ubuntu1~12.04_amd64.deb) ...
Unpacking replacement libgcc1 ...
dpkg: error processing /var/cache/apt/archives/libgcc1_1%3a4.8.1-2ubuntu1~12.04_amd64.deb (--unpack):
 trying to overwrite '/lib/x86_64-linux-gnu/libgcc_s.so.1', which is also in package gcc-4.6 4.6.3-1ubuntu5
Errors were encountered while processing:
 /var/cache/apt/archives/libgcc1_1%3a4.8.1-2ubuntu1~12.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

so I remove gcc 4.6:

sudo apt-get remove gcc-4.6
sudo apt-get update
apt-get: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory

Now apt-get, vi can't work any more.

6 Answers 6

16

This isn't a genuine fix, but a workaround.

The correct course of action is to install gcc-multilib, with apt-get install gcc-multilib

1
  • This helped like charme on Ubuntu 5.4.0-6ubuntu1~16.04.5! Why is it a workaround? Nov 23, 2017 at 13:31
5

I copy a libgcc_s.so.1 from other computer to /lib/x86_64-linux-gnu/

Then the problem solved.

I install gcc-4.7 again, it succeed.

3

installing gcc-multilib is the only thing that helped for me, i am running ubuntu 15. Thank you!

1
  • Ubuntu 16 and this worked for me as well
    – smac89
    May 18, 2016 at 1:13
2

(I stumbled upon the same issue years later, and nobody except Aylwyn Lake addresses the original situation where apt-get does not work)

So, if you face this error message when running apt:

apt: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory

you can still hopefully bring back libgcc_s.so.1. Here are two solutions:

  • install a .deb package with dpkg instead of apt. You should find such a package on pkgs.org - be sure to select the right version. Then run sudo dpkg -i packagename.deb
  • find this file somewhere else on your harddrive and place a copy in the folder /lib/x86_64-linux-gnu.
    You can search all across your disk with the command find / -name "libgcc_s.so.1".
    You may also find this file on a live or installation device (CD, USB stick) if you have one
0

I follow iaeiou 's suggesstion and solve this problem successfully for my Jetson-tx2 (arm64 system) with the help of my another PC.

First, I download the libgcc1-dbg_6.3.0-18+deb9u1_arm64.deb from this website

http://http.us.debian.org/debian/pool/main/g/gcc-6/

Then I use scp to sent this deb package to my Jetson-tx2

/home/my_usrname $  scp /home/my_usrname/libgcc1_6.3.0-18+deb9u1_arm64.deb [email protected]:/home/usrname

Finally I switch to Jetson-tx2 and install this deb package

/home/tx2-usrname $  sudo dpkg -i libgcc1_6.3.0-18+deb9u1_arm64.deb

ps: maybe you also need to download the gcc-6-base as the dependence of the libgcc1-xxxx.deb, which is in https://packages.debian.org/stretch/gcc-6-base or http://http.us.debian.org/debian/pool/main/g/gcc-6/ and use the same method.

Sorry for my poor English.

0

I was unable to make any of the other solutions work; however, I did get this resolved.

Running the find command above, I was able to locate 32-bit copies of the file but came up empty in /lib/ and /usr/lib/. After some digging around I came across this:

https://packages.ubuntu.com/search?suite=trusty&arch=amd64&mode=exactfilename&searchon=contents&keywords=libgcc_s.so.1

/usr/lib/gcc-snapshot/lib/libgcc_s.so.1 gcc-snapshot
/usr/lib/gcc-snapshot/lib32/libgcc_s.so.1   gcc-snapshot
/usr/lib/gcc-snapshot/libx32/libgcc_s.so.1  gcc-snapshot

This was the first package I saw with a reference to this file outside of /lib32, /libx32. So with nothing else to lose, I gave this a try:

$ sudo apt-get install gcc-snapshot

Still broken; however, now I can find these:

$ sudo find / -name "libgcc_s.so.1"
...
/usr/lib/gcc-snapshot/lib/libgcc_s.so.1
/usr/lib/gcc-snapshot/lib32/libgcc_s.so.1
/usr/lib/gcc-snapshot/libx32/libgcc_s.so.1
/usr/lib/x86_64-linux-gnu/libgcc_s.so.1
/usr/lib32/libgcc_s.so.1
/usr/libx32/libgcc_s.so.1
...

So there it is, /usr/lib/gcc-snapshot/lib/libgcc_s.so.1 after adding this directory to LD_LIBRARY_PATH I tried again and it worked...

$ export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/lib/gcc-snapshot/lib

Lastly I just copied the file /usr/lib/gcc-snapshot/lib/libgcc_s.so.1 to /usr/lib/libgcc_s.so.1 and all seems good.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .