获取 Chrono C++库(Boost::sandbox)可以工作

发布于 2024-10-06 21:29:42 字数 850 浏览 5 评论 0原文

我想从 Boost 沙箱尝试 Chrono 。它似乎支持很多东西并且应该稳定。

我的系统上安装了 Boost 1.44 版本(包括所需的 boost_system lib)并采用了沙箱版本(下载版本较旧,并且缺少例如ratio.hpp 文件)。

但它没有编译。尝试编译文档中的简单示例,并链接 boost_system (在 scons 中使用 LIBS=['boost_system']),每次都会发生以下错误:

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.

这似乎是链接器错误。我做错了什么?我在 1.44 版本中链接了 boost_system(通过 scons),并且已经尝试与旧版本 1.40 进行相同的操作。

有什么建议吗?您是如何设置 chrono 的使用的?

谢谢。

sascha

编辑: 此帖子,这是在谈论兼容性问题,让我认为沙盒版本的 Chrono 应该能够与 boost 1.44 一起工作。

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, which is talking about compatibility issues, let me think that the sandbox version of Chrono should be able to work with boost 1.44.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪冰清 2024-10-13 21:29:42

安装 Chrono 文档,您需要构建并链接 Chrono 库,或者定义 BOOST_CHRONO_INLINED

我在从 trunk checkout 构建 Chrono 时遇到了问题,但这可能与 Chrono 文档中提到的 type_traits 不兼容有关。

我能够使用以下 SConstruct 构建示例程序(修复命名空间错误后):

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')

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')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文