Setup: library com
uses library http
which in the namespace http
contains class ConnectionPool
. ConnectionPool
has method boost::network::http::client::response post(boost::network::http::client::request req);
where http_request is boost::network::http::client::request
env:
c++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
GNU Make 4.1
Cmake 3.15.3
Files:
- where is how Boost is included on paste bin
This is how the function is declared
boost::network::http::client::response
post(boost::network::http::client::request req, unsigned timeoutMs);
post()
is called like this in com
connectionPool.post(http_request, 4000);
I have a strange problem with CMake configuration: when using post
in com
linker (ld) returns 1 with error:
undefined reference to http::HTTPConnectionPool::post(boost::network::http::basic_request<boost::network::http::tags::http_default_8bit_udp_resolve>)'
However if I remove boost request from the signature of post
, everything compiles and works just fine. From that I can conclude that the problem is in linking boost
to the http
library, but I'm unable to find it, so here are CMakeFile's
http/CMakeLists.txt
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} http_srcs)
add_library(http ${http_srcs})
target_link_libraries(http PRIVATE pthread ${Boost_LIBRARIES} cppnetlib-uri)
com/CMakeFiles.txt
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} com_srcs)
add_library(com ${com_srcs})
target_link_libraries(com PRIVATE jsoncpp cppnetlib-uri ${OpenCV_LIBRARIES} ${Boost_LIBRARIES})
linking them together in main/CMakeLists.txt
# some code skipped there
target_link_libraries(main
config api rdm anm web com http dab log jsoncpp
${Boost_LIBRARIES}
)
I have tried already:
- renaming namespace from http to something else to check if there is possible collision
- link http to com in
com/CMakeLists.txt
- change order in main/CMakeLists.txt target_link_libraries()
- this answer https://stackoverflow.com/a/12205075/6429920
Another functions and constuctors from ConnectionPool
work fine, the problem occurs only when using boost request as one of the parameters.
The strange thing is function with the same signature works in com
.