首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用-fPIC重新编译

用-fPIC重新编译
EN

Stack Overflow用户
提问于 2019-02-28 20:05:29
回答 1查看 2.4K关注 0票数 1

我写这个命令:

代码语言:javascript
复制
gcc drr.c -o drr -pthread -lcdsl -L./../synch_implementations -I./../synch_implementations

我不明白为什么我会得到这样的回应:

代码语言:javascript
复制
usr/bin/ld: ./../synch_implementations/libcdsl.a(cdsl_queue_list.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
usr/bin/ld: ./../synch_implementations/libcdsl.a(cdsl_deque_list.o): relocation R_X86_64_32S against symbol `cdsl_deque_list_lock_based_pthread_push_tail' can not be used when making a PIE object; recompile with -fPIC
usr/bin/ld: ./../synch_implementations/libcdsl.a(cdsl_lock.o): relocation R_X86_64_32S against symbol `cdsl_pthread_lock_request' can not be used when making a PIE object; recompile with -fPIC
usr/bin/ld: final link failed: Nonrepresentable section on output
ollect2: error: ld returned 1 exit status

谁能帮我弄明白出什么事了吗?

备注:

1)我使用ubuntu (通过VirtualBox)。

2)我很缺乏经验,所以这可能不是一个很好的问题。

EN

回答 1

Stack Overflow用户

发布于 2019-02-28 21:03:20

解决方案:当您编译./synch_implementations/libcdsl.a时,您需要添加一个额外的"-fPIC“标志来生成独立于位置的代码(见上面的注释)。

备注:在生成库对象代码时,通常需要使用PIC标志,因为它创建相对于全局偏移表(GOT)的对象,该表随后允许将库对象与代码链接。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54933437

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档