Today, I tried to build Boost.Log
on Arch Linux
, but encountered following errors:
......
undefined reference to `boost::log::v2s_mt_posix::aux::stream_provider<char>::allocate_compound(boost::log::v2s_mt_posix::record&)'
undefined reference to `boost::log::v2s_mt_posix::aux::stream_provider<char>::release_compound(boost::log::v2s_mt_posix::aux::stream_provider<char>::stream_compound*)'
undefined reference to `boost::log::v2s_mt_posix::sources::aux::get_severity_level()'
undefined reference to `boost::log::v2s_mt_posix::aux::unhandled_exception_count()'
undefined reference to `boost::log::v2s_mt_posix::core::open_record(boost::log::v2s_mt_posix::attribute_set const&)'
undefined reference to `boost::log::v2s_mt_posix::core::push_record_move(boost::log::v2s_mt_posix::record&)'
undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()'
undefined reference to `boost::log::v2s_mt_posix::core::get_logging_enabled() const'
undefined reference to `boost::log::v2s_mt_posix::record_view::public_data::destroy(boost::log::v2s_mt_posix::record_view::public_data const*)'
......
After some investigation, I find at least on Arch Linux
, some modules need to be specified explicitly (E.g., log
) while some not (E.g., graph
). Besides, I also need claim that I want static library:
SET(Boost_USE_STATIC_LIBS ON)
FIND_PACKAGE(Boost REQUIRED COMPONENTS log)
Then use Boost_LIBRARIES
in linking executable file:
TARGET_LINK_LIBRARIES(... ${Boost_LIBRARIES})
Reference:
stackoverflow.
Thanks for that. After reading many, many pages on this problem, your answer was the only one that worked. I also had to insert
SET (CMAKE_C_FLAGS “-Wall -std=c++14 -fvisibility=hidden -fvisibility-inlines-hidden”)
to get rid of most of the “direct access in function ‘boost::log…” messages. Unfortunately some of them are still here.