Reputation: 93
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 ( libshared.so ). 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
Upvotes: 3
Views: 2304
Reputation: 15716
Try this:
set_property(TARGET TheirLib PROPERTY POSITION_INDEPENDENT_CODE ON)
This will set the fPIC option on the 3rd party project.
Upvotes: 0
Reputation: 93
there was not way to make any workaround. I had to write to 3rd party library developers to compile once again with -fPIC
Upvotes: 3