pulsar-client-cpp not able to build with static link
See original GitHub issueExpected 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
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (9 by maintainers)
Top GitHub Comments
@f7753 You can update clang-format version, because in CMakeLists.txt:
Or, we can ignore
make check-format
. In centos7 OS, the default version of clang is3.4.2
Then in
apachepulsar/pulsar-build:centos-7
image, when i execmake -j12
, error as follows:I tried to exec
yum install -y libstdc++-static.x86_64
, this problem was fixed.BTW, when I compile these code in docker environment, I use the default CPU resource settings, and then I compile with the param -j12, it would throw the error below:
So, if you see the log above, please make sure that your compile params match the docker resource settings.