3

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

bez
  • 93
  • 9

2 Answers2

3

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

bez
  • 93
  • 9
0

Try this:

set_property(TARGET TheirLib PROPERTY POSITION_INDEPENDENT_CODE ON)

This will set the fPIC option on the 3rd party project.

Source for this answer

Community
  • 1
  • 1
101010
  • 14,866
  • 30
  • 95
  • 172