diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f46dc0ee5..88369c06ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,7 +202,11 @@ include_directories( ${OPENSSL_INCLUDE_DIR} ) +set(WL_START_GROUP "-Wl,--start-group") +set(WL_END_GROUP "-Wl,--end-group") + set(DYNAMIC_LIB + ${WL_START_GROUP} ${GFLAGS_LIBRARY} ${PROTOBUF_LIBRARIES} ${LEVELDB_LIB} @@ -220,7 +224,7 @@ else() list(APPEND DYNAMIC_LIB ${OPENSSL_SSL_LIBRARY}) endif() -set(BRPC_PRIVATE_LIBS "-lgflags -lprotobuf -lleveldb -lprotoc -lssl -lcrypto -ldl -lz") +set(BRPC_PRIVATE_LIBS ${WL_START_GROUP} "-lgflags -lprotobuf -lleveldb -lprotoc -lssl -lcrypto -ldl -lz") if(WITH_GLOG) set(DYNAMIC_LIB ${DYNAMIC_LIB} ${GLOG_LIB}) @@ -249,6 +253,9 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") "-Wl,-U,_ProfilerStop") endif() +set(DYNAMIC_LIB "${DYNAMIC_LIB} ${WL_END_GROUP}") +set(BRPC_PRIVATE_LIBS "${BRPC_PRIVATE_LIBS} ${WL_END_GROUP}") + # for *.so set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/lib) # for *.a