wangrufeng opened a new issue, #3063:
URL: https://github.com/apache/brpc/issues/3063

   **Describe the bug**
   
    When compiling brpc with glog, the linker reports:
   
   ```
   > Linking protoc-gen-mcpack
   g++ -o protoc-gen-mcpack -std=c++0x -DBRPC_WITH_GLOG=1 -DGFLAGS_NS=google 
-D__const__=__unused__ -g -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D_GNU_SOURCE 
-DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-D__STDC_CONSTANT_MACROS -DNDEBUG 
-DBRPC_REVISION=\"1.10.0\|HEAD\|75763d4c\|2024-07-23T10:25:56+08:00\" -O2 -pipe 
-Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter 
-fno-omit-frame-pointer -Wno-aligned-new -I./src -I/usr/include/ -L/usr/lib64 
-Xlinker "-(" src/idl_options.pb.cc src/mcpack2pb/generator.o libbrpc.a 
-Wl,-Bstatic -lprotobuf -lprotoc -lglog -Wl,-Bdynamic -Xlinker "-)" -lpthread 
-lssl -lcrypto -ldl -lz -lrt -lgflags -lleveldb
   > Copying to output/include
   > Copying to output/lib
   libbrpc.a(symbolize.o): In function 
`google::InstallSymbolizeOpenObjectFileCallback(int (*)(unsigned long, unsigned 
long&, unsigned long&, char*, int))':
   brpc/src/butil/third_party/symbolize/symbolize.cc:90: multiple definition of 
`google::InstallSymbolizeOpenObjectFileCallback(int (*)(unsigned long, unsigned 
long&, unsigned long&, char*, int))'
   /usr/lib64/libglog.a(symbolize.cc.o):(.text+0x1f): first defined here
   ```
   
   **Root Cause**:
   
   - This issue was maybe introduced in PR #2684 (测试在该commit前的代码可链接通过,之后的会出现该问题)
   - `InstallSymbolizeOpenObjectFileCallback()` in 
`src/butil/third_party/symbolize/symbolize.cc` is not marked as `BAIDU_WEAK`, 
causing a symbol conflict with glog
   
   **To Reproduce**
   
   1. Build brpc >=1.10 with glog (`-lglog`).
   2. Observe linker error due to duplicate symbol.
   
   **Expected behavior**
   
   Mark `InstallSymbolizeOpenObjectFileCallback()` as `BAIDU_WEAK` to prevent 
symbol collision
   
   **Versions**
   OS: Anolis OS 8.6
   Compiler: 8.5.0 20210514
   brpc: >=1.10
   protobuf: 3.14


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to