/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libsnappy.a(snappy.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
Describe the bug (描述bug)
编译example出错: incubator-brpc/example/echo_c++# make -j
Generating echo.pb.cc /usr/bin/protoc --cpp_out=. --proto_path=. echo.proto Compiling client.o g++ -c -I/usr/include/ -I../../output/include -DBRPC_WITH_GLOG=0 -DGFLAGS_NS=google -g -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer client.cpp -o client.o Compiling server.o g++ -c -I/usr/include/ -I../../output/include -DBRPC_WITH_GLOG=0 -DGFLAGS_NS=google -g -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer server.cpp -o server.o Compiling echo.pb.o g++ -c -I/usr/include/ -I../../output/include -DBRPC_WITH_GLOG=0 -DGFLAGS_NS=google -g -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer echo.pb.cc -o echo.pb.o Linking echo_client g++ -L/usr/lib/x86_64-linux-gnu -L../../output/lib -Xlinker "-(" echo.pb.o client.o -Wl,-Bstatic -lgflags -lprotobuf -lleveldb -lsnappy -lbrpc -Wl,-Bdynamic -Xlinker "-)" -lpthread -lssl -lcrypto -ldl -lz -lrt -o echo_client Linking echo_server g++ -L/usr/lib/x86_64-linux-gnu -L../../output/lib -Xlinker "-(" echo.pb.o server.o -Wl,-Bstatic -lgflags -lprotobuf -lleveldb -lsnappy -lbrpc -Wl,-Bdynamic -Xlinker "-)" -lpthread -lssl -lcrypto -ldl -lz -lrt -o echo_server /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libsnappy.a(snappy.o): relocation R_X86_64_32S against
.rodata' 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 Makefile:69: recipe for target 'echo_client' failed make: *** [echo_client] Error 1 make: *** Waiting for unfinished jobs.... /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libsnappy.a(snappy.o): relocation R_X86_64_32S against.rodata' 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 Makefile:77: recipe for target 'echo_server' failed make: *** [echo_server] Error 1 rm echo.pb.cc
To Reproduce (复现方法)
编译example
Expected behavior (期望行为) 成功编译
Versions (各种版本) OS: debian 9(4.19) Compiler: gcc brpc: master protobuf:1.2.1-2 amd64
Additional context/screenshots (更多上下文/截图)
应该是/usr/lib/x86_64-linux-gnu/libsnappy.a这个库编译的时候没有加-fPIC选项
应该是/usr/lib/x86_64-linux-gnu/libsnappy.a这个库编译的时候没有加-fPIC选项
直接安装的包,brpc依赖这个是不是只能自己编译libsnappy-dev了?
Encounter the same question. Who knows the solution? Thank you.