在OSX 10.7.2上使用boost 1.48提升日志

时间:2012-01-06 16:49:46

标签: c++ macos boost

我从https://boost-log.svn.sourceforge.net/svnroot/boost-log/trunk/中提取了最新的BOOST日志,并试图在osx lion(10.7.2)上针对我当前的BOOST安装(1.47)进行构建,并抱怨它需要提升1.48。

所以我拉下来建造了BOOST 1.48,一切都很顺利。然后我更新了我的BOOST安装,并像这样运行bootstrap:

/bootstrap.sh --with-libraries=log --prefix=/usr/local 
    --includedir=/usr/local/include --libdir=/usr/local/lib

此时一切都很好。然而,现在,当我跑:

sudo ./b2

我收到以下错误:

...found 2606 targets...
...updating 9 targets...
darwin.compile.c++ bin.v2/libs/log/build/darwin-4.2.1/release/threading-multi/tick_count.o
libs/log/src/tick_count.cpp:220:5: error: #error Boost.Log: POSIX timers not 
supported on your platform

"g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -dynamic 
-no-cpp-    precomp -gdwarf-2 -fexceptions -fPIC  -DBOOST_ALL_NO_LIB=1
DBOOST_DATE_TIME_DYN_LINK=1 - DBOOST_FILESYSTEM_DYN_LINK=1 
-DBOOST_LOG_BUILDING_THE_LIB=1 -DBOOST_LOG_DLL - DBOOST_LOG_USE_NATIVE_SYSLOG=1 
-DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_THREAD_POSIX - DBOOST_THREAD_USE_DLL=1 -
DDATE_TIME_INLINE -DNDEBUG  -I"." -c -o  "bin.v2/libs/log/build/darwin-4.2.1/release/threading-multi/tick_count.o"  "libs/log/src/tick_count.cpp"

...failed darwin.compile.c++ bin.v2/libs/log/build/darwin-4.2.1/release/threading-multi/tick_count.o...
...skipped <pbin.v2/libs/log/build/darwin-4.2.1/release/threading-multi>libboost_log.dylib for lack of <pbin.v2/libs/log/build/darwin-4.2.1/release/threading-multi>tick_count.o...
...skipped <pstage/lib>libboost_log.dylib for lack of <pbin.v2/libs/log/build/darwin- 4.2.1/release/threading-multi>libboost_log.dylib...
...skipped <pbin.v2/libs/log/build/darwin-4.2.1/release/threading-multi>libboost_log_setup.dylib for lack of <pbin.v2/libs/log/build/darwin-4.2.1/release/threading-multi>libboost_log.dylib...
...skipped <pstage/lib>libboost_log_setup.dylib for lack of <pbin.v2/libs/log/build/darwin-4.2.1/release/threading-multi>libboost_log_setup.dylib...
darwin.compile.c++ bin.v2/libs/log/build/darwin-4.2.1/release/link-static/threading-multi/tick_count.o
libs/log/src/tick_count.cpp:220:5: error: #error Boost.Log: POSIX timers not supported on  your platform

"g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -no-cpp-precomp -gdwarf-2 -fexceptions  -DBOOST_ALL_NO_LIB=1 -DBOOST_LOG_BUILDING_THE_LIB=1 -DBOOST_LOG_USE_NATIVE_SYSLOG=1 -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_POSIX -DBOOST_THREAD_USE_LIB=1 -DDATE_TIME_INLINE -DNDEBUG  -I"." -c -o "bin.v2/libs/log/build/darwin-4.2.1/release/link-static/threading-multi/tick_count.o" "libs/log/src/tick_count.cpp"

...failed darwin.compile.c++ bin.v2/libs/log/build/darwin-4.2.1/release/link-static/threading-multi/tick_count.o...
...skipped <pbin.v2/libs/log/build/darwin-4.2.1/release/link-static/threading-multi>libboost_log.a(clean) for lack of <pbin.v2/libs/log/build/darwin-4.2.1/release/link-static/threading-multi>tick_count.o...
...skipped <pbin.v2/libs/log/build/darwin-4.2.1/release/link-static/threading-multi>libboost_log.a for lack of <pbin.v2/libs/log/build/darwin-4.2.1/release/link-static/threading-multi>tick_count.o...
...skipped <pstage/lib>libboost_log.a for lack of <pbin.v2/libs/log/build/darwin-4.2.1/release/link-static/threading-multi>libboost_log.a...
...failed updating 2 targets...
...skipped 7 targets...

我查看了BOOST日志安装的东西,并且有一些指令,但没有明显的关于此。有人给我一些关于此的线索吗?我在堆栈溢出或网络上找不到任何东西,这让我觉得我错过了什么。没有得到支持的posix定时器是一个非常确定的消息......

提前感谢。

2 个答案:

答案 0 :(得分:2)

此问题已在r655中修复。

问题是Darwin没有提供clock_gettime()的POSIX扩展功能。但是,Darwin确实在mach/mach_time.h中提供了一个名为mach_absolute_time()的高分辨率单色时钟。从r655开始,Boost Log在Mac OS上使用此功能。

如果您想毫不费力地安装最新的Boost版本,并享受C ++ 11带来的好处,请查看my custom Portfile。例如,它允许您按如下方式安装Boost:

sudo port install boost +cxx11 +log +debug +no_single

其中+log变体提取最新的SVN版本。

答案 1 :(得分:1)

简要查看代码,看起来boost-log并不是为了支持没有Posix定时器实现的Mac OS X而编写的。