braft icon indicating copy to clipboard operation
braft copied to clipboard

libbrpc.a is statically linked into libbraft.so

Open tangruize opened this issue 3 years ago • 0 comments

Hi, I built the atomic example with -DEXAMPLE_LINK_SO=on to reduce target sizes. But ./atomic_server failed:

ERROR: something wrong with flag 'log_as_json' in file '/project/brpc/src/butil/logging.cc'.  One possibility: file '/project/brpc/src/butil/logging.cc' is being linked both statically and dynamically into this executable.

It seems that libbraft.so is linked against libbrpc.a, so that it also contains some definitions of brpc, which causes the conflict. As a fix, I think libbrpc.a in line 70 of the top CMakeLists.txt is not necessary. Fix:

# Remove "libbrpc.a" in line 70, /CMakeLists.txt
#find_library(BRPC_LIB NAMES libbrpc.a brpc)
find_library(BRPC_LIB NAMES brpc)

tangruize avatar Dec 17 '20 07:12 tangruize