“relocation R_X86_64_32S against ” linking Error

前端 未结 5 1835
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 04:23

I\'m Trying to Link a static Library to a shared library , I\'m Getting the Following error

/usr/bin/ld: ../../../libraries/log4cplus/liblog4cplus.a(fileappender.o         


        
5条回答
  •  醉话见心
    2020-11-28 04:54

    Assuming you are generating a shared library, most probably what happens is that the variant of liblog4cplus.a you are using wasn't compiled with -fPIC. In linux, you can confirm this by extracting the object files from the static library and checking their relocations:

    ar -x liblog4cplus.a  
    readelf --relocs fileappender.o | egrep '(GOT|PLT|JU?MP_SLOT)'
    

    If the output is empty, then the static library is not position-independent and cannot be used to generate a shared object.

    Since the static library contains object code which was already compiled, providing the -fPIC flag won't help.

    You need to get ahold of a version of liblog4cplus.a compiled with -fPIC and use that one instead.

提交回复
热议问题