kubo/funchook

static compilation error

elsisoft opened this issue · 2 comments

hi. when I am trying compile a shared library with static libfunchook.a I have compilation errors
can you solve it ?
gcc -o mydll.so mydll.c -fPIC -shared -L. -lfunchook -D_GNU_SOURCE
/usr/bin/ld: ./libfunchook.a(funchook.c.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: ./libfunchook.a(funchook_x86.c.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ./libfunchook.a(funchook_unix.c.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: ./libfunchook.a(disasm_distorm.c.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status

kubo commented

Could you insert the following code after this line?

  set_target_properties(funchook-static PROPERTIES POSITION_INDEPENDENT_CODE ON)

yes, with this code has beed compiling ok, thanks