views:

38

answers:

1

Hi, This problem is related to This question I asked yesterday. Now it seems that the linker flag --whole-archive forces the test object to be included in the binary. However, in linking with,

g++ main.cpp -o app -Wl,--whole-archive -L/home/dumindara/intest/test.a -Wl,-no--whole-archive

I get the following error:

/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -lgcc_s

What to do?

+1  A: 

.a files are meant to be statically linked, and so are not compiled with -fPIC. Consequently, you cannot make a shared library from it.

Chris Jester-Young
I don't think the problem is with the static lib. I agree that using `-fPIC` is pointless. How do I link correctly?
nakiya