I'm working on a shared library with a various of dependency libraries.
They are all currently linked dynamically (shared object).

I'd like a few of the libraries linked statically TO the main shared object.
When I go ahead and try to link these libraries (.a) I get an error from ld:

/usr/local/lib/libTest.a(...): relocation R_X86_64_32S against 'vtable for ...' can not be used when making a shared object; recompile with -fPIC.
/usr/local/lib/libTest.a: could not read symbols: Bad value

Nothing is wrong with that static library (libTest.a) though, it works if I link it along with my main shared object, to some client executable.

I tried to add -fPIC to my CXX flags, as was suggested.

How to I help this problem - if it is possible? :)


as the error show it is a 64 bit machine, you need to include -fPIC at your compailation line and it should work then.

This article has been dead for over six months. Start a new discussion instead.