cristian
cristian

Reputation: 526

How can I use static lib in Shared Library project in Eclipse CDT

I have a Shared Library Project which builds only if I add -fPIC to the Compiler command ( this solves the issue ).

When I try to use a static library in this project I get a similar issue but in this situation I cannot fix with -fPIC:

libtest.a(exception.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC

Could I get some help please on how I can link this successfully ? I've tried adding -fPIC to the linker option also but I get the same error.

I am using GCC Compiler on Linux.

Upvotes: 0

Views: 80

Answers (1)

Jonah Graham
Jonah Graham

Reputation: 7970

From the question it appears you are updating the link time to add -fPIC, but you need to recompile libtest.a with -fPIC so that the relocations created in exception.o and the other objects in the library are PIC compatible.

Upvotes: 1

Related Questions