|
Boost : |
From: Karmethia Thompson (kcthomps_at_[hidden])
Date: 2020-09-15 14:34:24
Good morning,
I am trying to create a logger that uses Boost Log. I was successful
getting my code to compile with 1.63.0, so I know that I am not too far off
of the mark. cmake/make throws a linking issues whenever I attempt to
create a sink:
typedef sinks::synchronous_sink<
sinks::text_ostream_backend > text_sink;
boost::shared_ptr< text_sink > sink = boost::make_shared< text_sink
>();
or create file sink
logging::add_file_log
(
keywords::file_name = log_specs.log_file,
keywords::rotation_size = 10 * 1024 * 1024,
keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0,
0),
keywords::filter = min_severity || severity >= file_severity,
keywords::format =
(
expr::stream
<< expr::format_date_time<boost::posix_time::ptime>("TimeStamp",
"%Y-%m-%d_%H:%M:%S.%f")
<< ": [" << severity << "]"
<< expr::smessage
),
keywords::auto_flush = true //flush to file..
);
My code will compile 95% and then produce the following:
CMakeFiles/main.dir/src/Logger.cpp.o: In function
`boost::enable_if_c<(boost::log::v2_mt_posix::aux::is_character_type<wchar_t>::value&&boost::log::v2_mt_posix::aux::is_character_type<char>::value)&&((sizeof
(wchar_t))!=(sizeof (char))), bool>::type
boost::log::v2_mt_posix::aux::code_convert<wchar_t, char,
std::char_traits<char>, std::allocator<char> >(wchar_t const*, unsigned
long, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >&, unsigned long, std::locale const&)':
Logger.cpp:(.text._ZN5boost3log11v2_mt_posix3aux12code_convertIwcSt11char_traitsIcESaIcEEENS_11enable_if_cIXaaaasrNS2_17is_character_typeIT_EE5valuesrNS8_IT0_EE5valuenestS9_stSB_EbE4typeEPKS9_mRNSt7__cxx1112basic_stringISB_T1_T2_EEmRKSt6locale[_ZN5boost3log11v2_mt_posix3aux12code_convertIwcSt11char_traitsIcESaIcEEENS_11enable_if_cIXaaaasrNS2_17is_character_typeIT_EE5valuesrNS8_IT0_EE5valuenestS9_stSB_EbE4typeEPKS9_mRNSt7__cxx1112basic_stringISB_T1_T2_EEmRKSt6locale]+0x37):
undefined reference to
`boost::log::v2_mt_posix::aux::code_convert_impl(wchar_t const*, unsigned
long, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >&, unsigned long, std::locale const&)'
CMakeFiles/main.dir/src/Logger.cpp.o: In function `void
boost::log::v2_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::recursive_mutex,
boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>
>(boost::log::v2_mt_posix::record_view const&, boost::recursive_mutex&,
boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>&)':
Logger.cpp:(.text._ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS_15recursive_mutexENS2_26basic_text_ostream_backendIcEEEEvRKNS1_11record_viewERT_RT0_[_ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS_15recursive_mutexENS2_26basic_text_ostream_backendIcEEEEvRKNS1_11record_viewERT_RT0_]+0x141):
undefined reference to
`boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>::consume(boost::log::v2_mt_posix::record_view
const&, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)'
CMakeFiles/main.dir/src/Logger.cpp.o: In function `void
boost::log::v2_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::recursive_mutex,
boost::log::v2_mt_posix::sinks::text_file_backend>(boost::log::v2_mt_posix::record_view
const&, boost::recursive_mutex&,
boost::log::v2_mt_posix::sinks::text_file_backend&)':
Logger.cpp:(.text._ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS_15recursive_mutexENS2_17text_file_backendEEEvRKNS1_11record_viewERT_RT0_[_ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS_15recursive_mutexENS2_17text_file_backendEEEvRKNS1_11record_viewERT_RT0_]+0x141):
undefined reference to
`boost::log::v2_mt_posix::sinks::text_file_backend::consume(boost::log::v2_mt_posix::record_view
const&, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)'
CMakeFiles/main.dir/src/Logger.cpp.o: In function `void
boost::log::v2_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::log::v2_mt_posix::aux::fake_mutex,
boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>
>(boost::log::v2_mt_posix::record_view const&,
boost::log::v2_mt_posix::aux::fake_mutex&,
boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>&)':
Logger.cpp:(.text._ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS1_3aux10fake_mutexENS2_26basic_text_ostream_backendIcEEEEvRKNS1_11record_viewERT_RT0_[_ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS1_3aux10fake_mutexENS2_26basic_text_ostream_backendIcEEEEvRKNS1_11record_viewERT_RT0_]+0x141):
undefined reference to
`boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>::consume(boost::log::v2_mt_posix::record_view
const&, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)'
CMakeFiles/main.dir/src/Logger.cpp.o: In function `void
boost::log::v2_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::log::v2_mt_posix::aux::fake_mutex,
boost::log::v2_mt_posix::sinks::text_file_backend>(boost::log::v2_mt_posix::record_view
const&, boost::log::v2_mt_posix::aux::fake_mutex&,
boost::log::v2_mt_posix::sinks::text_file_backend&)':
Logger.cpp:(.text._ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS1_3aux10fake_mutexENS2_17text_file_backendEEEvRKNS1_11record_viewERT_RT0_[_ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS1_3aux10fake_mutexENS2_17text_file_backendEEEvRKNS1_11record_viewERT_RT0_]+0x141):
undefined reference to
`boost::log::v2_mt_posix::sinks::text_file_backend::consume(boost::log::v2_mt_posix::record_view
const&, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [main] Error 1
make[1]: *** [CMakeFiles/main.dir/all] Error 2
Can someone please help? I have tried everything from trying to dynamically
and statically link. I've added both "log" and "log_setup" to the
find_packages in cmake and have also explicitly specified the locations of
those libraries as well.
Please let me know if there is anything else to try.
Thanks
-- Karmethia Thompson Applied Mathematics, PhD
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk