bez bez - 1 year ago 71
Linux Question

link static library (without -fPIC) to shared library on 64bit OS

I write programm in c++, from which will be made shared library - and done it will be used by JNI. I have 3rd party library ( libexample.a ) and need to link it to shared library ( ). The problem is, that I work on 64bit CentOS and -fPIC is needed to create shared lib, but 3rd party library wasnt compiled with -fPIC.

Until building I recive:

/usr/bin/ld: /home/tom/Project/src/libexample.a(SomeObject.o): relocation R_X86_64_32 against 'someData' can not be used when making a shared object; recompile with -fPIC

Is it possible to make shared library in this situation? (I dont have source code of libexample.a ...)

Is there any workaround to make it work? Even ideas when I will have to write additional apps.

I hope that my question isn`t duplicate (more or less) because I spent long time at searching of possibilities.
Thanks, bez

bez bez
Answer Source

there was not way to make any workaround. I had to write to 3rd party library developers to compile once again with -fPIC