c++ - 如何使用 boost lib 编译 c++ 代码?在 Ubuntu 上

标签 c++ boost ubuntu

#include <iostream>
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

我使用了上面显示的标题。 在 Boost 官网上找不到帮助。

最佳答案

假设您的代码中没有错误,您需要链接正确的 boost 库:boost_thread、boost_system 和 boost_date_time 是您引用的,所以

#include <iostream>
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
int main()
{
}

该程序使用以下命令编译:

g++ -o test test.cc -lboost_system -lboost_date_time -lboost_thread

关于c++ - 如何使用 boost lib 编译 c++ 代码?在 Ubuntu 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5891339/

相关文章:

c++ - 将 $ORIGIN 与 setuid 应用程序一起使用不会按预期失败

ubuntu - 不同的 Crontab?

c++ - 基于范围的循环的 BOOST_FOREACH 和 c++11 之间的区别?

c++ - 如何设置标志(cpp-netlib)

c++ - 英特尔c/c++编译器: "could not locate executable icc" (and ecc)

ubuntu - 如何在 Ubuntu 12.04 中使用 Boehm 垃圾收集器

c++ - 如何将 "upgrade"mutex 所有权从共享升级?

c++ - 为什么 QJsonValue::toDouble 中有精度损失?

C++/CMake :Undefined reference to imwrite in OpenCV

C++ 使用自定义权重 boost prim 的算法?