vli02 opened a new issue #1964: pulsar-client-cpp not able to build with static link URL: https://github.com/apache/incubator-pulsar/issues/1964 #### Expected behavior Build pulsar-client-cpp lib with static linking all libs. Set LINK_STATIC to ON in CMakeList.txt and run ./docker-build.sh, expect to build the cpp client lib with static linking. #### Actual behavior Build failed. #### Steps to reproduce In pulsar/pulsar-client-cpp/ $ git diff CMakeLists.txt diff --git a/pulsar-client-cpp/CMakeLists.txt b/pulsar-client-cpp/CMakeLists.txt index 38a47742..7fb08401 100644 --- a/pulsar-client-cpp/CMakeLists.txt +++ b/pulsar-client-cpp/CMakeLists.txt @@ -24,7 +24,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules") option(BUILD_TESTS "Build tests" ON) MESSAGE(STATUS "BUILD_TESTS: " ${BUILD_TESTS}) -option(LINK_STATIC "Link against static libraries" OFF) +option(LINK_STATIC "Link against static libraries" ON) MESSAGE(STATUS "LINK_STATIC: " ${LINK_STATIC}) option(USE_LOG4CXX "Build with Log4cxx support" OFF) $ ./docker-build.sh ... [ 38%] Linking CXX shared library libpulsar.so ... /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libboost_filesystem.a(operations.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libboost_filesystem.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status lib/CMakeFiles/pulsarShared.dir/build.make:2097: recipe for target 'lib/libpulsar.so.2.1.0-incubating-SNAPSHOT' failed make[2]: *** [lib/libpulsar.so.2.1.0-incubating-SNAPSHOT] Error 1 make[2]: Leaving directory '/pulsar/pulsar-client-cpp' CMakeFiles/Makefile2:158: recipe for target 'lib/CMakeFiles/pulsarShared.dir/all' failed make[1]: *** [lib/CMakeFiles/pulsarShared.dir/all] Error 2 make[1]: Leaving directory '/pulsar/pulsar-client-cpp' Makefile:86: recipe for target 'all' failed make: *** [all] Error 2 #### System configuration **Pulsar version**: 2.0
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
