Hi,

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? :)

Thaanks!

Recommended Answers

Make sure all object files were compiled with -fPIC by doing a full rebuild of the shared library.

See here as well:
http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=3

Jump to Post

All 2 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.