软件环境:MacOSX 10.11 + QtCreator + Boost 1.60
首先编译Boost自带的例子测试能否正常编译。此处使用的文件在boost_1_60_0/libs/log/example/basic_usage。因为使用的是QtCreator进行编译,使用了Qt的pro文件进行代码和编译管理,但封装Boost的log库和Qt没有关系,可以直接使用。首先记录几个编译时遇到的问题。
1. 可以使用dylib库而不能使用a的静态库,否则编译时会提示错误:
ld: warning: object file (/usr/local/boost/lib/libboost_thread.a(thread.o)) was built for newer OSX version (10.11) than being linked (10.7) ld: warning: object file (/usr/local/boost/lib/libboost_system.a(error_code.o)) was built for newer OSX version (10.11) than being linked (10.7) ld: warning: object file (/usr/local/boost/lib/libboost_thread.a(once.o)) was built for newer OSX version (10.11) than being linked (10.7) Undefined symbols for architecture x86_64: "boost::log::v2_mt_posix::attributes::named_scope::push_scope(boost::log::v2_mt_posix::attributes::named_scope_entry const&)", referenced from: boost::log::v2_mt_posix::attributes::named_scope::sentry::sentry(boost::log::v2_mt_posix::basic_string_literal<char, std::__1::char_traits<char> > const&, boost::log::v2_mt_posix::basic_string_literal<char, std::__1::char_traits<char> > const&, unsigned int, boost::log::v2_mt_posix::attributes::named_scope_entry::scope_name_type) in main.o
原因有可能是静态块编译的问题,不太确定,需要继续跟踪。
2. 使用到的动态链接库
libboost_system.dylib libboost_filesystem.dylib libboost_thread.dylib libboost_atomic.dylib libboost_chrono.dylib libboost_regex.dylib libboost_log_setup.dylib libboost_log.dylib