1. 使用动态库时,要定义 BOOST_LOG_DYN_LINK 或者 BOOST_ALL_DYN_LINK
否则会出现如下错误:
CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `xxxx::Init(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)‘: /xxxx.cpp:54: undefined reference to `boost::log::v2s_mt_posix::sinks::file::rotation_at_time_point::rotation_at_time_point(unsigned char, unsigned char, unsigned char)‘ /xxxx.cpp:59: undefined reference to `boost::log::v2s_mt_posix::core::get()‘ /xxxx.cpp:60: undefined reference to `boost::log::v2s_mt_posix::core::add_sink(boost::shared_ptr<boost::log::v2s_mt_posix::sinks::sink> const&)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::record::reset()‘: /usr/include/boost/log/core/record.hpp:153: undefined reference to `boost::log::v2s_mt_posix::record_view::public_data::destroy(boost::log::v2s_mt_posix::record_view::public_data const*)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `~basic_logger‘: /usr/include/boost/log/sources/basic_logger.hpp:82: undefined reference to `boost::log::v2s_mt_posix::attribute_set::~attribute_set()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `~once_block_sentry‘: /usr/include/boost/log/utility/once_block.hpp:85: undefined reference to `boost::log::v2s_mt_posix::aux::once_block_sentry::rollback()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::aux::once_block_sentry::executed() const‘: /usr/include/boost/log/utility/once_block.hpp:90: undefined reference to `boost::log::v2s_mt_posix::aux::once_block_sentry::enter_once_block() const‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::expressions::tag::message::get_name()‘: /usr/include/boost/log/expressions/message.hpp:56: undefined reference to `boost::log::v2s_mt_posix::aux::default_attribute_names::message()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `current_process_id‘: /usr/include/boost/log/attributes/current_process_id.hpp:49: undefined reference to `boost::log::v2s_mt_posix::aux::this_process::get_id()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::attributes::current_thread_id::impl::dispatch(boost::log::v2s_mt_posix::type_dispatcher&)‘: /usr/include/boost/log/attributes/current_thread_id.hpp:69: undefined reference to `boost::log::v2s_mt_posix::aux::this_thread::get_id()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::attributes::current_thread_id::impl::detach_from_thread()‘: /usr/include/boost/log/attributes/current_thread_id.hpp:79: undefined reference to `boost::log::v2s_mt_posix::aux::this_thread::get_id()‘ /usr/include/boost/log/attributes/current_thread_id.hpp:79: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator new(unsigned long)‘ /usr/include/boost/log/attributes/current_thread_id.hpp:79: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `~impl‘: /usr/include/boost/log/attributes/attribute.hpp:71: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ /usr/include/boost/log/attributes/attribute.hpp:71: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `~impl‘: /usr/include/boost/log/attributes/attribute_value.hpp:76: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ /usr/include/boost/log/attributes/attribute_value.hpp:76: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `current_thread_id‘: /usr/include/boost/log/attributes/current_thread_id.hpp:89: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator new(unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::add_common_attributes()‘: /usr/include/boost/log/utility/setup/common_attributes.hpp:53: undefined reference to `boost::log::v2s_mt_posix::core::get()‘ /usr/include/boost/log/utility/setup/common_attributes.hpp:56: undefined reference to `boost::log::v2s_mt_posix::aux::default_attribute_names::line_id()‘ /usr/include/boost/log/utility/setup/common_attributes.hpp:56: undefined reference to `boost::log::v2s_mt_posix::core::add_global_attribute(boost::log::v2s_mt_posix::attribute_name const&, boost::log::v2s_mt_posix::attribute const&)‘ /usr/include/boost/log/utility/setup/common_attributes.hpp:59: undefined reference to `boost::log::v2s_mt_posix::aux::default_attribute_names::timestamp()‘ /usr/include/boost/log/utility/setup/common_attributes.hpp:59: undefined reference to `boost::log::v2s_mt_posix::core::add_global_attribute(boost::log::v2s_mt_posix::attribute_name const&, boost::log::v2s_mt_posix::attribute const&)‘ /usr/include/boost/log/utility/setup/common_attributes.hpp:62: undefined reference to `boost::log::v2s_mt_posix::aux::default_attribute_names::process_id()‘ /usr/include/boost/log/utility/setup/common_attributes.hpp:62: undefined reference to `boost::log::v2s_mt_posix::core::add_global_attribute(boost::log::v2s_mt_posix::attribute_name const&, boost::log::v2s_mt_posix::attribute const&)‘ /usr/include/boost/log/utility/setup/common_attributes.hpp:66: undefined reference to `boost::log::v2s_mt_posix::aux::default_attribute_names::thread_id()‘ /usr/include/boost/log/utility/setup/common_attributes.hpp:66: undefined reference to `boost::log::v2s_mt_posix::core::add_global_attribute(boost::log::v2s_mt_posix::attribute_name const&, boost::log::v2s_mt_posix::attribute const&)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `constant‘: /usr/include/boost/log/attributes/constant.hpp:76: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator new(unsigned long)‘ /usr/include/boost/log/attributes/constant.hpp:76: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `counter‘: /usr/include/boost/log/attributes/counter.hpp:87: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator new(unsigned long)‘ /usr/include/boost/log/attributes/counter.hpp:87: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ /usr/include/boost/log/attributes/counter.hpp:89: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator new(unsigned long)‘ /usr/include/boost/log/attributes/counter.hpp:89: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ /usr/include/boost/log/attributes/counter.hpp:91: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator new(unsigned long)‘ /usr/include/boost/log/attributes/counter.hpp:91: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `basic_clock‘: /usr/include/boost/log/attributes/clock.hpp:71: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator new(unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::sources::basic_composite_logger<char, boost::log::v2s_mt_posix::sources::logger, boost::log::v2s_mt_posix::sources::single_thread_model, boost::log::v2s_mt_posix::sources::features<void, void, void, void, void, void, void, void, void, void> >::open_record()‘: /usr/include/boost/log/sources/basic_logger.hpp:566: undefined reference to `boost::log::v2s_mt_posix::core::get_logging_enabled() const‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `~record_pump‘: /usr/include/boost/log/sources/record_ostream.hpp:278: undefined reference to `boost::log::v2s_mt_posix::aux::unhandled_exception_count()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `basic_logger‘: /usr/include/boost/log/sources/basic_logger.hpp:136: undefined reference to `boost::log::v2s_mt_posix::core::get()‘ /usr/include/boost/log/sources/basic_logger.hpp:136: undefined reference to `boost::log::v2s_mt_posix::attribute_set::attribute_set()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `~attribute_value_impl‘: /usr/include/boost/log/attributes/attribute_value_impl.hpp:49: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ /usr/include/boost/log/attributes/attribute_value_impl.hpp:49: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `~impl‘: /usr/include/boost/log/attributes/counter.hpp:62: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ /usr/include/boost/log/attributes/counter.hpp:62: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::shared_ptr<boost::log::v2s_mt_posix::sinks::synchronous_sink<boost::log::v2s_mt_posix::sinks::text_file_backend> > boost::log::v2s_mt_posix::aux::add_file_log<boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::format, char const [36]>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::time_based_rotation, boost::log::v2s_mt_posix::sinks::file::rotation_at_time_point const>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::rotation_size, int const>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::open_mode, std::_ios_Openmode const>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const>, boost::parameter::aux::empty_arg_list> > > > > >(boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::format, char const [36]>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::time_based_rotation, boost::log::v2s_mt_posix::sinks::file::rotation_at_time_point const>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::rotation_size, int const>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::open_mode, std::_Ios_Openmode const>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const>, boost::parameter::aux::empty_arg_list> > > > > const&)‘: /usr/include/boost/log/utility/setup/file.hpp:81: undefined reference to `boost::log::v2s_mt_posix::sinks::text_file_backend::set_file_collector(boost::shared_ptr<boost::log::v2s_mt_posix::sinks::file::collector> const&)‘ /usr/include/boost/log/utility/setup/file.hpp:82: undefined reference to `boost::log::v2s_mt_posix::sinks::text_file_backend::scan_for_files(boost::log::v2s_mt_posix::sinks::file::scan_method, bool)‘ /usr/include/boost/log/utility/setup/file.hpp:94: undefined reference to `boost::log::v2s_mt_posix::core::get()‘ /usr/include/boost/log/utility/setup/file.hpp:94: undefined reference to `boost::log::v2s_mt_posix::core::add_sink(boost::shared_ptr<boost::log::v2s_mt_posix::sinks::sink> const&)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::detail::sp_if_not_array<boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char> >::type boost::make_shared<boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char> >()‘: /usr/include/boost/smart_ptr/make_shared_object.hpp:146: undefined reference to `boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>::basic_text_ostream_backend()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::record boost::log::v2s_mt_posix::sources::basic_logger<char, boost::log::v2s_mt_posix::sources::logger, boost::log::v2s_mt_posix::sources::single_thread_model>::open_record_unlocked<boost::parameter::aux::empty_arg_list>(boost::parameter::aux::empty_arg_list const&)‘: /usr/include/boost/log/sources/basic_logger.hpp:260: undefined reference to `boost::log::v2s_mt_posix::core::open_record(boost::log::v2s_mt_posix::attribute_set const&)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `record_pump‘: /usr/include/boost/log/sources/record_ostream.hpp:259: undefined reference to `boost::log::v2s_mt_posix::aux::stream_provider<char>::allocate_compound(boost::log::v2s_mt_posix::record&)‘ /usr/include/boost/log/sources/record_ostream.hpp:259: undefined reference to `boost::log::v2s_mt_posix::aux::unhandled_exception_count()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `~auto_release‘: /usr/include/boost/log/sources/record_ostream.hpp:243: 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*)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::core::push_record(boost::rv<boost::log::v2s_mt_posix::record>&)‘: /usr/include/boost/log/core/core.hpp:308: undefined reference to `boost::log::v2s_mt_posix::core::push_record_move(boost::log::v2s_mt_posix::record&)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `void boost::log::v2s_mt_posix::sinks::text_file_backend::construct<boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::format, char const [36]>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::time_based_rotation, boost::log::v2s_mt_posix::sinks::file::rotation_at_time_point const>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::rotation_size, int const>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::open_mode, std::_Ios_Openmode const>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const>, boost::parameter::aux::empty_arg_list> > > > > >(boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::format, char const [36]>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::time_based_rotation, boost::log::v2s_mt_posix::sinks::file::rotation_at_time_point const>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::rotation_size, int const>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::open_mode, std::_Ios_Openmode const>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const>, boost::parameter::aux::empty_arg_list> > > > > const&)‘: /usr/include/boost/log/sinks/text_file_backend.hpp:511: undefined reference to `boost::log::v2s_mt_posix::sinks::text_file_backend::construct(boost::filesystem::path const&, std::_Ios_Openmode, unsigned long, boost::log::v2s_mt_posix::aux::light_function<bool ()()> const&, bool)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::basic_formatter<char> boost::log::v2s_mt_posix::parse_formatter<char>(char const*)‘: /usr/include/boost/log/utility/setup/formatter_parser.hpp:207: undefined reference to `boost::log::v2s_mt_posix::basic_formatter<char> boost::log::v2s_mt_posix::parse_formatter<char>(char const*, char const*)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::detail::sp_ms_deleter<boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char> >::destroy()‘: /usr/include/boost/smart_ptr/make_shared_object.hpp:57: undefined reference to `boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>::~basic_text_ostream_backend()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::detail::sp_ms_deleter<boost::log::v2s_mt_posix::sinks::text_file_backend>::destroy()‘: /usr/include/boost/smart_ptr/make_shared_object.hpp:57: undefined reference to `boost::log::v2s_mt_posix::sinks::text_file_backend::~text_file_backend()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::aux::light_function<bool ()()>::impl<boost::log::v2s_mt_posix::sinks::file::rotation_at_time_point>::invoke_impl(boost::log::v2s_mt_posix::aux::light_function<bool ()()>::impl_base*)‘: /usr/include/boost/log/detail/light_function_pp.hpp:77: undefined reference to `boost::log::v2s_mt_posix::sinks::file::rotation_at_time_point::operator()() const‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::visitation_result boost::log::v2s_mt_posix::value_visitor_invoker<boost::mpl::vector2<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, boost::log::v2s_mt_posix::fallback_to_none>::operator()<boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >&> >(boost::log::v2s_mt_posix::attribute_name const&, boost::log::v2s_mt_posix::attribute_value_set const&, boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >&>) const‘: /usr/include/boost/log/attributes/value_visitation.hpp:182: undefined reference to `boost::log::v2s_mt_posix::attribute_value_set::find(boost::log::v2s_mt_posix::attribute_name) const‘ /usr/include/boost/log/attributes/value_visitation.hpp:183: undefined reference to `boost::log::v2s_mt_posix::attribute_value_set::end() const‘ /usr/include/boost/log/attributes/value_visitation.hpp:191: undefined reference to `boost::log::v2s_mt_posix::aux::attach_attribute_name_info(boost::exception&, boost::log::v2s_mt_posix::attribute_name const&)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::array<std::pair<boost::log::v2s_mt_posix::type_info_wrapper, void*>, 2ul> const& boost::log::v2s_mt_posix::aux::type_sequence_dispatcher<boost::mpl::vector2<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > >::get_dispatching_map<boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >&> >()‘: /usr/include/boost/log/utility/type_dispatch/static_type_dispatcher.hpp:160: undefined reference to `boost::log::v2s_mt_posix::aux::once_block_sentry::commit()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >& boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >::formatted_write<wchar_t>(wchar_t const*, long)‘: /usr/include/boost/log/utility/formatting_ostream.hpp:560: undefined reference to `boost::log::v2s_mt_posix::aux::code_convert(wchar_t const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::locale const&)‘ /usr/include/boost/log/utility/formatting_ostream.hpp:570: undefined reference to `boost::log::v2s_mt_posix::aux::code_convert(wchar_t const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::locale const&)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `~impl‘: /usr/include/boost/log/attributes/clock.hpp:59: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ /usr/include/boost/log/attributes/clock.hpp:59: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `~impl_generic‘: /usr/include/boost/log/attributes/counter.hpp:112: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ /usr/include/boost/log/attributes/counter.hpp:112: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `~impl_dec‘: /usr/include/boost/log/attributes/counter.hpp:162: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o:/usr/include/boost/log/attributes/counter.hpp:162: more undefined references to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ follow CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::attributes::basic_clock<boost::log::v2s_mt_posix::attributes::local_time_traits>::impl::get_value()‘: /usr/include/boost/log/attributes/clock.hpp:63: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator new(unsigned long)‘ /usr/include/boost/log/attributes/clock.hpp:63: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `boost::log::v2s_mt_posix::attribute_value boost::log::v2s_mt_posix::attributes::make_attribute_value<unsigned int>(unsigned int const&)‘: /usr/include/boost/log/attributes/attribute_value_impl.hpp:116: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator new(unsigned long)‘ /usr/include/boost/log/attributes/attribute_value_impl.hpp:116: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `void boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::mutex, boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char> >(boost::log::v2s_mt_posix::record_view const&, boost::mutex&, boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>&)‘: /usr/include/boost/log/sinks/basic_sink_frontend.hpp:445: undefined reference to `boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>::consume(boost::log::v2s_mt_posix::record_view const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `void boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::mutex, boost::log::v2s_mt_posix::sinks::text_file_backend>(boost::log::v2s_mt_posix::record_view const&, boost::mutex&, boost::log::v2s_mt_posix::sinks::text_file_backend&)‘: /usr/include/boost/log/sinks/basic_sink_frontend.hpp:445: undefined reference to `boost::log::v2s_mt_posix::sinks::text_file_backend::consume(boost::log::v2s_mt_posix::record_view const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `void boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::log::v2s_mt_posix::aux::fake_mutex, boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char> >(boost::log::v2s_mt_posix::record_view const&, boost::log::v2s_mt_posix::aux::fake_mutex&, boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>&)‘: /usr/include/boost/log/sinks/basic_sink_frontend.hpp:445: undefined reference to `boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>::consume(boost::log::v2s_mt_posix::record_view const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `void boost::log::v2s_mt_posix::sinks::basic_sink_frontend::flush_backend_impl<boost::mutex, boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char> >(boost::mutex&, boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>&, mpl_::bool_<true>)‘: /usr/include/boost/log/sinks/basic_sink_frontend.hpp:233: undefined reference to `boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>::flush()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `void boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::log::v2s_mt_posix::aux::fake_mutex, boost::log::v2s_mt_posix::sinks::text_file_backend>(boost::log::v2s_mt_posix::record_view const&, boost::log::v2s_mt_posix::aux::fake_mutex&, boost::log::v2s_mt_posix::sinks::text_file_backend&)‘: /usr/include/boost/log/sinks/basic_sink_frontend.hpp:445: undefined reference to `boost::log::v2s_mt_posix::sinks::text_file_backend::consume(boost::log::v2s_mt_posix::record_view const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `void boost::log::v2s_mt_posix::sinks::basic_sink_frontend::flush_backend_impl<boost::mutex, boost::log::v2s_mt_posix::sinks::text_file_backend>(boost::mutex&, boost::log::v2s_mt_posix::sinks::text_file_backend&, mpl_::bool_<true>)‘: /usr/include/boost/log/sinks/basic_sink_frontend.hpp:233: undefined reference to `boost::log::v2s_mt_posix::sinks::text_file_backend::flush()‘ CMakeFiles/xxxx.dir/xxxx.cpp.o: In function `~attribute_value_impl‘: /usr/include/boost/log/attributes/attribute_value_impl.hpp:49: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ /usr/include/boost/log/attributes/attribute_value_impl.hpp:49: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ /usr/include/boost/log/attributes/attribute_value_impl.hpp:49: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘ /usr/include/boost/log/attributes/attribute_value_impl.hpp:49: undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)‘
2. 使用静态库时,注意 libboost_log_setup.a和libboost_log.a 两个库的顺序, 正确的顺序是 libboost_log_setup.a 应该在 libboost_log.a 之前.
否则会出现一下错误:
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../lib64/libboost_log_setup.a(formatter_parser.o): In function `boost::log::v2s_mt_posix::(anonymous namespace)::formatter_grammar<wchar_t>::formatter_grammar()‘: formatter_parser.cpp:(.text+0x6015): undefined reference to `boost::log::v2s_mt_posix::aux::encoding_specific<boost::spirit::char_encoding::standard_wide>::graph‘ formatter_parser.cpp:(.text+0x6541): undefined reference to `boost::log::v2s_mt_posix::aux::encoding_specific<boost::spirit::char_encoding::standard_wide>::alnum‘ formatter_parser.cpp:(.text+0x6548): undefined reference to `boost::log::v2s_mt_posix::aux::encoding_specific<boost::spirit::char_encoding::standard_wide>::space‘ formatter_parser.cpp:(.text+0x65c2): undefined reference to `boost::log::v2s_mt_posix::aux::encoding_specific<boost::spirit::char_encoding::standard_wide>::alpha‘ formatter_parser.cpp:(.text+0x683c): undefined reference to `boost::log::v2s_mt_posix::aux::encoding_specific<boost::spirit::char_encoding::standard_wide>::print‘ /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../lib64/libboost_log_setup.a(formatter_parser.o): In function `boost::log::v2s_mt_posix::(anonymous namespace)::formatter_grammar<char>::formatter_grammar()‘: formatter_parser.cpp:(.text+0x7efa): undefined reference to `boost::log::v2s_mt_posix::aux::encoding_specific<boost::spirit::char_encoding::standard>::graph‘ formatter_parser.cpp:(.text+0x8307): undefined reference to `boost::log::v2s_mt_posix::aux::encoding_specific<boost::spirit::char_encoding::standard>::alnum‘ formatter_parser.cpp:(.text+0x830e): undefined reference to `boost::log::v2s_mt_posix::aux::encoding_specific<boost::spirit::char_encoding::standard>::space‘ formatter_parser.cpp:(.text+0x8388): undefined reference to `boost::log::v2s_mt_posix::aux::encoding_specific<boost::spirit::char_encoding::standard>::alpha‘ formatter_parser.cpp:(.text+0x85f4): undefined reference to `boost::log::v2s_mt_posix::aux::encoding_specific<boost::spirit::char_encoding::standard>::print‘