apt-get: error loading libgcc_s.so.1

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.


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


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.


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


(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