-
Notifications
You must be signed in to change notification settings - Fork 650
Fix linker error: undefined reference to ...v2s_mt_posix.... on shared boost libs build #1484
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to prevent linker error like: undefined reference to ...v2s_mt_posix....
Can you please update Boost-log example to reproduce this error. Which toolchain/platform you have used?
cmake/templates/BoostConfig.cmake.in
Outdated
@@ -150,3 +150,10 @@ endif() | |||
if(TARGET Boost::chrono) | |||
hunter_add_rt_library(Boost::chrono) | |||
endif() | |||
|
|||
if(TARGET Boost::log AND NOT Boost_USE_STATIC_LIBS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should analyze BUILD_SHARED_LIBS
instead, it's used in Boost build scheme.
Like this:
if(TARGET Boost::log AND "@BUILD_SHARED_LIBS@")
# ...
endif()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is changed ... needs a test.
Well, how can I set the
I doesn't matter. It's failing on all platforms/toolchain. Boost log use the C++ namespace as ABI :-) .... for example:
as static:
v2 = boost log version 2 If you link against a boost log shared lib, you should add the Maybe I create in the future a pull request in the |
Okay, not "update" but "create new", take a look at
Okay, just need one toolchain for CI testing. |
I added a boost-log-shared example I test the example with following command: cmake -Hhunter/examples/Boost-log-shared -B~/Build/build-hunter-test -DCMAKE_TOOLCHAIN_FILE=~/Development/polly/clang-cxx14.cmake It build on Development/hunter/examples/Boost-log-shared/foo.cpp:(.text+0x1a): undefined reference to »boost::log::v2s_mt_posix::trivial::logger::get()« |
@@ -0,0 +1,375 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit by mistake ... it is removed.
find_package(Boost CONFIG REQUIRED log filesystem system chrono thread regex date_time atomic) | ||
|
||
add_executable(foo foo.cpp) | ||
target_link_libraries(foo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clean-up trailing whitespaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's clean-up
@@ -150,3 +150,10 @@ endif() | |||
if(TARGET Boost::chrono) | |||
hunter_add_rt_library(Boost::chrono) | |||
endif() | |||
|
|||
if(TARGET Boost::log AND "@BUILD_SHARED_LIBS@") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are changing internal Boost files please update PACKAGE_INTERNAL_DEPS_ID
of all files from cmake/projects/Boost
directory. See:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated all PACKAGE_INTERNAL_DEPS_ID
in cmake/projects/Boost
@@ -18,5 +18,5 @@ hunter_download( | |||
Boost | |||
PACKAGE_COMPONENT | |||
atomic | |||
PACKAGE_INTERNAL_DEPS_ID "31" | |||
PACKAGE_INTERNAL_DEPS_ID "32" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update for PACKAGE_INTERNAL_DEPS_ID
in hunter.cmake.in
is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ups... sorry ... done.
Set in BoostConfig.cmake BOOST_LOG_DYN_LINK for Boost::log target to prevent linker error like:
on shared lib build.
See also: https://www.boost.org/doc/libs/1_67_0/libs/log/doc/html/log/installation/config.html