baidu / braft

An industrial-grade C++ implementation of RAFT consensus algorithm based on brpc, widely used inside Baidu to build highly-available distributed systems.
Apache License 2.0
3.95k stars 881 forks source link

编译braft时出现问题 #305

Open fzj200069 opened 3 years ago

fzj200069 commented 3 years ago

brpc已成功编译,编译braft时出现以下内容: [ 95%] Linking CXX shared library ../output/lib/libbraft.so /usr/bin/ld: /usr/local/lib/libleveldb.a(db_impl.cc.o): relocation R_X86_64_PC32 against symbol `_ZTVN7leveldb12SnapshotImplE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status make[2]: [src/CMakeFiles/braft-shared.dir/build.make:158: output/lib/libbraft.so] Error 1make[1]: [CMakeFiles/Makefile2:146: src/CMakeFiles/braft-shared.dir/all] Error 2 make: *** [Makefile:152: all] Error 2 使用的leveldb为release1.23版,且成功编译并添加到了/usr/local/bin中,请问如何解决

PFZheng commented 3 years ago

看错误是leveldb的编译存在问题,需要添加-fPIC编译参数