简体   繁体   English

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

[英]How to compile c++ code with boost lib? on Ubuntu

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

I used headers shown above.我使用了上面显示的标题。 Cannot find help on Boost Official website.在 Boost 官方网站上找不到帮助。

Assuming no errors in your code, you need to link the correct boost libraries: boost_thread, boost_system, and boost_date_time are the ones you've referenced, so假设您的代码中没有错误,您需要链接正确的 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()
{
}

This program compiles with the following command:该程序使用以下命令编译:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM