开发者

Getting Chrono C++ library (Boost::sandbox) to work

开发者 https://www.devze.com 2023-01-30 03:21 出处:网络
i wanted to try out Chrono from the Boost sandbox. It seems to support a lot of stuff and should be stable.

i wanted to try out Chrono from the Boost sandbox. It seems to support a lot of stuff and should be stable.

I have Boost in version 1.44 installed on my system (incl. boost_system lib which is needed) and took the sandbox version (the download-version is older and misses for example the ratio.hpp file).

But it isn't compiling. Trying to compile the simple example from the documentation, with linking boost_system (in scons with LIBS=['boost_system']), the following error is occurring every time:

obj/main.o: In function `main':
/home/***/src/main.cpp:34: undefined reference to `boost::chrono::system_clock::now()'
scons: building terminated because of errors.

That seems to be a linker error. What did i do wrong? I have boost_system in version 1.44 linked (trough scons) and already tried the same with the older version 1.40.

Any tips? How did you setup your use of chrono?

Thanks.

sascha

Edit: This thread,开发者_如何学Go which is talking about compatibility issues, let me think that the sandbox version of Chrono should be able to work with boost 1.44.


As described in the Installing Chrono documentation, you either need to build and link the Chrono library, or define BOOST_CHRONO_INLINED.

I had problems building Chrono from the trunk checkout, but it's probably related to the type_traits incompatibility mentioned in the Chrono docs.

I was able to build the example program with the following SConstruct (after fixing namespace errors):

env = Environment(
    CPPDEFINES = ['BOOST_CHRONO_INLINED'],
    CPPPATH = ['/.../boost_1_44_0', ],
    LIBPATH = ['/.../boost_1_44_0/stage/lib', ],
    LIBS = ['boost_system'],
)

env.Program('chrono-test', 'main.cpp')
0

精彩评论

暂无评论...
验证码 换一张
取 消