3

I'm trying to use gcc-3.4 on the latest Ubuntu. The package is from debian snapshots.

It probably assumes different default directory structure, so for example I was forced to give it -I /usr/include/i386-linux-gnu/, which gcc-4 assumed implicitly.

Currently it compiles everything I gave it just fine, but it can't link. Even the simplest executable results the error:

$ gcc-3.4 ~/tmp.cc -o ~/tmp
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
Jason Aller
  • 139
  • 6
Elazar Leibovich
  • 436
  • 1
  • 4
  • 7

3 Answers3

6

Apparently you need to add the library /lib/i386-linux-gnu/libgcc_s.so.1 and the compiler expect the soft link /usr/lib/gcc/i486-linux-gnu/3.4.6/libgcc_s.so pointing it to the correct place, however:

$ ls -l /usr/lib/gcc/i486-linux-gnu/3.4.6/libgcc_s.so
lrwxrwxrwx 1 root root 18 2011-05-03 04:55 /usr/lib/gcc/i486-linux-gnu/3.4.6/libgcc_s.so -> /lib/libgcc_s.so.1

And

$ ls /lib/libgcc_s.so.1
ls: /lib/libgcc_s.so.1: No such file or directory

Fix the symlink, and all will be well

$ sudo ln /lib/i386-linux-gnu/libgcc_s.so.1  /usr/lib/gcc/i486-linux-gnu/3.4.6/libgcc_s.so

Now it works correctly!

$ g++-3.4   ~/tmp.cc -o ~/tmp
$
Elazar Leibovich
  • 436
  • 1
  • 4
  • 7
  • This is useful when working with the `davidva/gcc49` copr in Fedora. I was missing the libgcc_s.so in the right subdir `/opt/gcc-4.9.3/lib64/gcc/x86_64-fedoraunited-linux-gnu/4.9.3`. – bgStack15 Jan 21 '18 at 04:02
0

I had a similar problem, but in my case trying to install gcc 4.2 (to compile in Matlab Simulink) in Ubuntu 11.04

In my case I wrote:

sudo ln  /lib/x86_64-linux-gnu/libgcc_s.so.1  /usr/lib/gcc/x86_64-linux-gnu/4.2.3/libgcc_s.so

And now gcc-4.2 is compiling.

user9517
  • 114,104
  • 20
  • 206
  • 289
Juan
  • 1
  • You welcome! I'm really glad you found that helpful. You can upvote the answer and the question if you like them by clicking on the "up" button, to tell other users it was useful for you. – Elazar Leibovich May 08 '11 at 08:49
0

for me the command:

sudo ln /lib/i386-linux-gnu/libgcc_s.so.1  /usr/lib/gcc/i486-linux-gnu/3.4.6/libgcc_s.so

does not solve the issue.

This command, instead, does solve it:

sudo cp /lib/i386-linux-gnu/libgcc_s.so.1 /lib/libgcc_s.so.1
user9517
  • 114,104
  • 20
  • 206
  • 289
RlB
  • 1