I have a libstdc++_pic.a on my system (Ubuntu 12.04, gcc 4.6.3), presumably this is the version of libstdc++ created with -fPIC. I also have a libstdc++.a.
I see the following error when I try to statically link libstdc++ with a shared library via the -static-libstdc++ link flag:
:-1: error: /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a(functexcept.o): relocation R_X86_64_32 against `std::bad_exception::~bad_exception()' can not be used when making a shared object; recompile with -fPIC
So I'm assuming it is using the non pic version, as I would expect based on the default naming. How can I instruct the linker to use the libstdc++_pic.a file?
Update 1
The _pic version is in the 32 bit gcc subfolder at /usr/lib/gcc/x86_64-linux-gnu/4.6/32
, and I don't see a _pic version in the parent folder where the 64 bit versions are located. It appears that my version of gcc was not compiled with a 64 bit PIC static libstdc++.a.
Update 2 I was able to install the 64 bit version of libstdc++_pic.a by checking my gcc version and then installing the package:
gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
sudo apt-get install libstdc++6-4.6-pic
And now I see it in /usr/lib/gcc/x86_64-linux-gnu/4.6/
. Still need to figure out how to tell linker to use it.