You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2019/08/24 06:17:57 UTC

[GitHub] [incubator-brpc] NetWilliam opened a new issue #901: 链接 libbrpc.so 的时候出现错误, 依赖的静态库需要使用 -fPIC 方式编译

NetWilliam opened a new issue #901: 链接 libbrpc.so 的时候出现错误, 依赖的静态库需要使用 -fPIC 方式编译
URL: https://github.com/apache/incubator-brpc/issues/901
 
 
   **Describe the bug (描述bug)**
   静态库编译成功, 动态库链接的时候出现
   `/usr/bin/ld: /usr/local/lib64/libprotobuf.a(wire_format.cc.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
   /usr/bin/ld: /usr/local/lib64/libprotobuf.a(implicit_weak_message.cc.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
   /usr/bin/ld: /usr/local/lib64/libprotobuf.a(strtod.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
   /usr/bin/ld: /usr/local/lib64/libprotobuf.a(stringprintf.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
   /usr/bin/ld: /usr/local/lib64/libprotobuf.a(structurally_valid.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
   /usr/bin/ld: /usr/local/lib64/libprotobuf.a(strutil.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
   /usr/bin/ld: /usr/local/lib64/libprotobuf.a(any.cc.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
   /usr/bin/ld: /usr/local/lib64/libprotobuf.a(zero_copy_stream_impl.cc.o): relocation R_X86_64_32S against symbol `_ZTVN6google8protobuf2io15FileInputStreamE' can not be used when making a shared object; recompile with -fPIC`
   这样的错误
   
   **To Reproduce (复现方法)**
   安装各类依赖之后, 使用cmake 编译, 静态库可以成功编译  动态库无法正常编译.
   即使在修改 gflags, leveldb 和 protobuf 加上 -fPIC 选项之后编译出静态库安装到系统环境, 再来编译brpc 仍然会报错
   
   **Expected behavior (期望行为)**
   编译动态库成功
   
   **Versions (各种版本)**
   OS: CentOS Linux release 7.6.1810 (Core) 
   Compiler: g++ 4.8.5 
   
   brpc master, protobuf v3.7.0,  leveldb master, gflags master
   
   **Additional context/screenshots (更多上下文/截图)**
   
   ![image](https://user-images.githubusercontent.com/3966971/63633349-e3668500-c679-11e9-8ca5-f3f9c2f27be3.png)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org