问题
I am trying to make 32 bit library on a 64 bit Ubuntu box. I am creating .so as follows
gcc - shared -Wl,-soname,libtest.so *.o
I am getting /usr/bin/ld : relocation R_X86_64_PC32 against symbol "set_bright' cann't be used when making shared object;recompile with -fPIC.
Already I tried compiling with -fPIC. It didn't work.
Please let me know if I need to use any flag while compilation .c or some flag while creating .so
thanks,
回答1:
I believe you get that error if there you're calling a function declared as hidden, e.g.
int set_hidden(void) __attribute__((visibility("hidden")));
and it's not defined in the same shared object.
To solve it you have to also link the object file containing the definition of set_hidden
, or remove the call to it.
来源:https://stackoverflow.com/questions/9728213/shared-library-relocation-r-x86-64-pc32-error