boost使用log库编译报错

使用boost的log,用以下链接选项:

-lboost_system -lboost_thread -lboost_log -lboost_log_setup -lboost_filesystem -lpthread

当使用add_console_log函数编译链接时报错:

/usr/local/gcc/bin/g++ ../obj/timerServer.o ../obj/CWatchThread.o ../obj/CHttpRequest.o ../obj/CKeyCreater.o ../obj/CServerThread.o ../obj/CTimerThread.o -g -lboost_system -lboost_thread -lboost_log -lboost_log_setup -lboost_filesystem -lpthread -L/usr/local/boost/lib -o ../bin/timerServer
/usr/local/boost/lib/libboost_log_setup.a(default_formatter_factory.o): In function `void boost::log::v2s_mt_posix::type_dispatcher::callback_base::trampoline<boost::log::v2s_mt_posix::aux::(anonymous namespace)::default_formatter<char>::visitor, boost::log::v2s_mt_posix::aux::id<boost::log::v2s_mt_posix::aux::process> >(void*, boost::log::v2s_mt_posix::aux::id<boost::log::v2s_mt_posix::aux::process> const&)':
default_formatter_factory.cpp:(.text._ZN5boost3log12v2s_mt_posix15type_dispatcher13callback_base10trampolineINS1_3aux12_GLOBAL__N_117default_formatterIcE7visitorENS5_2idINS5_7processEEEEEvPvRKT0_[_ZN5boost3log12v2s_mt_posix3aux25default_formatter_factoryIcE16create_formatterERKNS1_14attribute_nameERKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESE_St4lessISE_ESaISt4pairIKSE_SE_EEE]+0x8): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& boost::log::v2s_mt_posix::aux::operator<< <char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, boost::log::v2s_mt_posix::aux::id<boost::log::v2s_mt_posix::aux::process> const&)'
/usr/local/boost/lib/libboost_log_setup.a(default_formatter_factory.o): In function `void boost::log::v2s_mt_posix::type_dispatcher::callback_base::trampoline<boost::log::v2s_mt_posix::aux::(anonymous namespace)::default_formatter<wchar_t>::visitor, boost::log::v2s_mt_posix::aux::id<boost::log::v2s_mt_posix::aux::process> >(void*, boost::log::v2s_mt_posix::aux::id<boost::log::v2s_mt_posix::aux::process> const&)':
default_formatter_factory.cpp:(.text._ZN5boost3log12v2s_mt_posix15type_dispatcher13callback_base10trampolineINS1_3aux12_GLOBAL__N_117default_formatterIwE7visitorENS5_2idINS5_7processEEEEEvPvRKT0_[_ZN5boost3log12v2s_mt_posix3aux25default_formatter_factoryIwE16create_formatterERKNS1_14attribute_nameERKSt3mapINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEESE_St4lessISE_ESaISt4pairIKSE_SE_EEE]+0xb): undefined reference to `std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& boost::log::v2s_mt_posix::aux::operator<< <wchar_t, std::char_traits<wchar_t> >(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >&, boost::log::v2s_mt_posix::aux::id<boost::log::v2s_mt_posix::aux::process> const&)'
collect2: error: ld returned 1 exit status

链接选项再加三个如下:

-lboost_system -lboost_thread -lboost_log -lboost_log_setup -lboost_filesystem -lpthread -lboost_locale -lboost_log -lboost_log_setup

编译正常通过了

最后发现下面三个库必须是这个顺序:

-lboost_log_setup -lboost_locale -lboost_log

中间可以穿插其它库,但是这三个的先后次序必须是这样的

转载于:https://my.oschina.net/beyondwxf/blog/1797741

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值