Hi,

I've tried to static linking Qpid Proton C++ 0.29.0 to my project  and after I linked all the .a library which are generated by Qpid Proton C++ cmake project the linker still shows undefined reference errors, few examples of the errors:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/usr/bin/ld: /home/pi/x/main.cpp:222: undefined reference to `proton::container::run()' /usr/bin/ld: /home/pi/x/main.cpp:222: undefined reference to `proton::container::~container()' /usr/bin/ld: /home/pi/x/main.cpp:222: undefined reference to `proton::container::~container()' /usr/bin/ld: CMakeFiles/x.dir/main.cpp.o:(.rodata._ZTV6client[_ZTV6client]+0x14): undefined reference to `proton::messaging_handler::on_container_stop(proton::container&)' /usr/bin/ld: CMakeFiles/x.dir/main.cpp.o:(.rodata._ZTV6client[_ZTV6client]+0x1c): undefined reference to `proton::messaging_handler::on_sendable(proton::sender&)' /usr/bin/ld: CMakeFiles/x.dir/main.cpp.o:(.rodata._ZTV6client[_ZTV6client]+0x20): undefined reference to `proton::messaging_handler::on_transport_open(proton::transport&)' /usr/bin/ld: CMakeFiles/x.dir/main.cpp.o:(.rodata._ZTV6client[_ZTV6client]+0x24): undefined reference to `proton::messaging_handler::on_transport_close(proton::transport&)'

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I've created a minimal as possible CMake based project to test the Qpid static linking. The test project contains a reference to Qpid Proton C++ repo (as cmake external project) and my project contains a 'main.cpp' which is a simple AMQP client sample code from Qpid Proton C++ repo.

Here is my CMakelists.txt content:

cmake_minimum_required(VERSION 3.13 FATAL_ERROR)

project(xxx CXX)

set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})

include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)

list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/external/cmake-modules")

set(CMAKE_CXX_STANDARD 17)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v -std=c++17 -lpthread -static-libgcc -static-libstdc++ -fdiagnostics-color=auto -lstdc++fs -latomic -g")

add_executable (x main.cpp)

include(ExternalProject)

########################################################
# apache qpid proton

ExternalProject_Add(qpid_ext
    PREFIX extern/qpid
    GIT_REPOSITORY    https://github.com/apache/qpid-proton.git
    GIT_TAG           0.29.0
    CMAKE_ARGS        -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
                      -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
                      -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
                      -DBUILD_WITH_CXX=ON
                      -DBUILD_CPP=ON
                      -DBUILD_CPP_03=OFF
                      -DBUILD_STATIC_LIBS=ON
                      #-DENABLE_WARNING_ERROR=OFF
                      #-DENABLE_UNDEFINED_ERROR=ON
                      #-DENABLE_LINKTIME_OPTIMIZATION=ON
                      #-DENABLE_HIDE_UNEXPORTED_SYMBOLS=OFF
                      -DENABLE_FUZZ_TESTING=OFF
                      -DFUZZ_LONG_TESTS=OFF
                      -DFUZZ_REGRESSION_TESTS=OFF
                      -DBUILD_TESTING=OFF
                      -DBUILD_BINDINGS="" # no bindings enabled
                      -DSYSINSTALL_BINDINGS=ON
    TEST_COMMAND      "" # do not run tests
    UPDATE_COMMAND    "" # do not check git repo again
)

ExternalProject_Get_Property(qpid_ext INSTALL_DIR)

set(qpid_INCLUDE_DIR ${INSTALL_DIR}/include)
file(MAKE_DIRECTORY ${qpid_INCLUDE_DIR})  # Must exists

add_library(qpid1 STATIC IMPORTED)
set_target_properties(qpid1 PROPERTIES
    IMPORTED_LOCATION ${INSTALL_DIR}/lib/libqpid-proton-core-static${CMAKE_STATIC_LIBRARY_SUFFIX}
    INTERFACE_INCLUDE_DIRECTORIES ${qpid_INCLUDE_DIR}
)
add_dependencies(qpid1 qpid_ext)

add_library(qpid2 STATIC IMPORTED)
set_target_properties(qpid2 PROPERTIES
    IMPORTED_LOCATION ${INSTALL_DIR}/lib/libqpid-proton-proactor-static${CMAKE_STATIC_LIBRARY_SUFFIX}
    INTERFACE_INCLUDE_DIRECTORIES ${qpid_INCLUDE_DIR}
)
add_dependencies(qpid2 qpid_ext)

add_library(qpid3 STATIC IMPORTED)
set_target_properties(qpid3 PROPERTIES
    IMPORTED_LOCATION ${INSTALL_DIR}/lib/libqpid-proton-static${CMAKE_STATIC_LIBRARY_SUFFIX}
    INTERFACE_INCLUDE_DIRECTORIES ${qpid_INCLUDE_DIR}
)
add_dependencies(qpid3 qpid_ext)

unset(INSTALL_DIR)

# apache qpid proton
########################################################

target_link_libraries (x qpid1 qpid2 qpid3)


The "ExternalProject" cmake works perfectly, its generating all the ".a" libs: 'libqpid-proton-core-static.a', 'libqpid-proton-proactor-static.a', 'libqpid-proton-static.a'. As you seen  above I linked all three ".a" lib to the executable without any luck.

Anybody has a hint how to resolve linking errors? Is this three ".a" lib covers/contains all the Qpid Proton C++ codebase or there should be more ".a" generated?

Note: If I cloning the Qpid Proton C++ repo and compiling & install it standalone (so the ".a" libs goes to the common /usr/local/lib) the static linking will not succeed either.

Thanks,

berge


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

Reply via email to