I try to reference a static *.a
library for my c++ project in CDT. I included it in
C/C++ Build -> Cross C++ Linker -> Libraries
But I get the error:
relocation R_X86_64_32S against symbol ... can not be used when making a shared object.
Now from what I have read so far I think this means the compiler thinks I am referencing a shared library, when it is a static library instead - Is that the case and if so what can do now? Is there any way to just use the *.a
libraries or do I have to recompile them as .so
- objects?
The problem is most probably coming from the fact that the static library is compiled without supporting position independent code. I don't know a way to fix it without recompiling the static library.
If you can recompile the static library, then assuming you are using gcc or clang, you have to add the -fPIC
flag to your compiler flags.
Without more information it is hard to give more advice. If you can provide a minimal, reproducible example, then I can help you with that.
In my case, I had just compiled it as *.a, so I was pretty sure a recompile again as *.a wouldn't work, there was no chance gcc was updated in the meantime. So I tried what you mentioned in the question already: removed the .a libs and recompiled&installed as .so and it worked. Thanks :D
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With