PDA

View Full Version : Natty Narwhal: cannot find -lgcc_s (broken gcc/g++)



genjix
May 6th, 2011, 02:37 AM
Hey,

I upgraded to Natty Narwhal and the compiler is broken. :( not being able to compile = expensive paper-weight.


$ gcc blaa.c
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status

It can work if I do:


$ g++ blaa.cpp -L /usr/lib/gcc/i686-linux-gnu/4.6/

Any ideas how to get this to work?

slavik
May 6th, 2011, 03:00 AM
use g++ to compile C++ code, not gcc. gcc is for C.

genjix
May 6th, 2011, 10:32 AM
use g++ to compile C++ code, not gcc. gcc is for C.

That has nothing to do with the errors I'm getting with both g++/gcc. The linker is failing to find gcc_s.


genjix:/tmp$ echo "int main() { return 0; }" > main.c && gcc main.c
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
genjix:/tmp$ echo "int main() { return 0; }" > main.cpp && g++ main.cpp
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
genjix:/tmp$ echo "int main() { return 0; }" > main.c && gcc main.c -L /usr/lib/gcc/i686-linux-gnu/4.6/
genjix:/tmp$ echo "int main() { return 0; }" > main.cpp && g++ main.cpp -L /usr/lib/gcc/i686-linux-gnu/4.6/


WTH? Why is Natty Narwhal so broken?

dwhitney67
May 6th, 2011, 01:49 PM
EDIT:

Never mind what I wrote below. Can you verify that you have the following directory on your system: /usr/lib/gcc/i686-linux-gnu/4.6/


--------------------------------------------------

Try running /sbin/ldconfig, as shown below:


sudo /sbin/ldconfig -v | grep "/usr/lib/gcc/i686-linux-gnu/4.6"

What I am interested in knowing is whether the path above is configured in your ld-cache. How did you install the development tools?

genjix
May 6th, 2011, 06:55 PM
Hey,

Thanks for your reply. The directory did indeed exist with the libgcc_s.so inside it.

But I use this computer for work so I simply wiped it clean and reinstalled Ubuntu... Need to code and that's the path of least resistance.

dwhitney67
May 7th, 2011, 12:24 AM
Hey,

Thanks for your reply. The directory did indeed exist with the libgcc_s.so inside it.

But I use this computer for work so I simply wiped it clean and reinstalled Ubuntu... Need to code and that's the path of least resistance.

Did you install the package "build-essential" (maybe plural with an 's' at the end)?

olness
May 9th, 2011, 08:09 PM
I upgraded from 10.10 to 11.04 and the link to libgcc_s was broken in the upgrade.
The bad link was: /lib/i386-linux-gnu/libgcc_s.so.1
The correct lib was: /usr/lib/gcc/i486-linux-gnu/3.4.6/libgcc_s.so
I re-created the link and this fixed my problem.

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

caspin
May 11th, 2011, 07:05 PM
I was having genjix's same problem. I could compile on maverick, but was unable to do so on natty. ld was unable to find libgcc_s.

The root of the problem was the libgcc_s package failed to upgrade. I had been using a ppa repo for the latest gcc when I was using maverick. Unfortunately the libgcc_s package had a version string that was newer than natty's version of libgcc_s.

The fix was simple. download maverick's default libgcc_s from packages.ubuntu.com and install it with `dpkg -i`.