I'm trying to link against the QPid Proton library, using static libs, and am getting lots of link errors. I am able to build with the shared libraries, but for this project we need to use static libs.
Here's the CMake file:
cmake_minimum_required(VERSION 3.0.0)
project(test-qpid VERSION 0.1.0)
include(CTest)
enable_testing()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-pie " )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v -std=c++17 -lpthread -static-libgcc -static-libstdc++ -fdiagnostics-color=auto")
set(THREADS_PREFER_PTHREAD_FLAG ON)
add_library(libpthread STATIC IMPORTED)
set_target_properties(libpthread PROPERTIES IMPORTED_LOCATION /usr/lib/x86_64-linux-gnu/libpthread.a)
set_target_properties(libpthread PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/include)
add_executable(test-qpid main.cpp)
find_library(QPID_PROTON_CORE NAMES qpid-proton-core-static)
if (NOT QPID_PROTON_CORE)
message(FATAL_ERROR, "QPid Proton core static library not found")
endif()
find_library(QPID_PROTON_PROACTOR NAMES qpid-proton-proactor-static)
if (NOT QPID_PROTON_PROACTOR)
message(FATAL_ERROR, "QPid Proton proactor static library not found")
endif()
find_library(QPID_PROTON NAMES qpid-proton-static)
if (NOT QPID_PROTON)
message(FATAL_ERROR, "QPid Proton static library not found")
endif()
find_library(QPID_PROTON_CPP NAMES qpid-proton-cpp-static)
if (NOT QPID_PROTON_CPP)
message(FATAL_ERROR, "QPid Proton CPP static library not found")
endif()
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include_directories("/usr/local/include")
set(LIBS ${QPID_PROTON_CORE} ${QPID_PROTON} ${QPID_PROTON_PROACTOR} ${QPID_PROTON_CPP})
target_link_libraries(test-qpid ${LIBS} libpthread)
include(CPack)
Here is a snippet of the output I'm seeing (there are lots more, which I've omitted for brevity):
-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. -lpthread CMakeFiles/test-qpid.dir/main.cpp.o /usr/local/lib/libqpid-proton-core-static.a /usr/local/lib/libqpid-proton-static.a /usr/local/lib/libqpid-proton-proactor-static.a /usr/local/lib/libqpid-proton-cpp-static.a /usr/lib/x86_64-linux-gnu/libpthread.a -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/9/crtend.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::close()':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:65: undefined reference to `pn_connection_close'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::error() const':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:171: undefined reference to `pn_connection_remote_condition'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::transport() const':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:52: undefined reference to `pn_connection_transport'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::open(proton::connection_options const&)':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:61: undefined reference to `pn_connection_open'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::virtual_host[abi:cxx11]() const':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:71: undefined reference to `pn_connection_remote_hostname'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::container_id[abi:cxx11]() const':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:75: undefined reference to `pn_connection_remote_container'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::user[abi:cxx11]() const':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:79: undefined reference to `pn_connection_transport'
[build] /usr/bin/ld: /home/user/src/qpid-proton/cpp/src/connection.cpp:79: undefined reference to `pn_transport_get_user'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::sessions() const':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:93: undefined reference to `pn_session_head'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::receivers() const':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:97: undefined reference to `pn_link_head'
[build] /usr/bin/ld: /home/user/src/qpid-proton/cpp/src/connection.cpp:101: undefined reference to `pn_link_next'
[build] /usr/bin/ld: /home/user/src/qpid-proton/cpp/src/connection.cpp:99: undefined reference to `pn_link_is_receiver'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::senders() const':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:107: undefined reference to `pn_link_head'
[build] /usr/bin/ld: /home/user/src/qpid-proton/cpp/src/connection.cpp:111: undefined reference to `pn_link_next'
[build] /usr/bin/ld: /home/user/src/qpid-proton/cpp/src/connection.cpp:109: undefined reference to `pn_link_is_sender'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::open_session(proton::session_options const&)':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:121: undefined reference to `pn_session'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::default_session()':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:133: undefined reference to `pn_session'
[build] /usr/bin/ld: /home/user/src/qpid-proton/cpp/src/connection.cpp:134: undefined reference to `pn_session_open'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::max_frame_size() const':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:175: undefined reference to `pn_connection_transport'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::max_sessions() const':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:179: undefined reference to `pn_connection_transport'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::idle_timeout() const':
[build] /home/user/src/qpid-proton/cpp/src/connection.cpp:183: undefined reference to `pn_connection_transport'
[build] /usr/bin/ld: /usr/local/lib/libqpid-proton-cpp-static.a(connection.cpp.o): in function `proton::connection::desired_capabilities() const':
I've been Googling for answers for days and have gotten nowhere. If anyone has any experience with QPid Proton I'd greatly appreciate some suggestions.