美文网首页
[习题29]解决:relocation R_X86_64_32

[习题29]解决:relocation R_X86_64_32

作者: AkuRinbu | 来源:发表于2018-12-28 20:00 被阅读33次

    问题解决

    • 提示错误
    $ cc -shared -o libex29.so libex29.o
    /usr/bin/ld: libex29.o: relocation R_X86_64_32 against `.rodata' 
    can not be used when making a shared object; 
    recompile with -fPIC
    libex29.o: error adding symbols: Bad value
    collect2: error: ld returned 1 exit status
    
    • 解决方法 : 添加-fPIC参数
    $ cc -fPIC -c libex29.c -o libex29.o
    $ cc -shared -o libex29.so libex29.o
    
    $ ls
    dbg.h  ex29.c  libex29.c  libex29.o  libex29.so
    

    参考资料

    相关文章

      网友评论

          本文标题:[习题29]解决:relocation R_X86_64_32

          本文链接:https://www.haomeiwen.com/subject/dgwelqtx.html