开发者

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

#include <iostream>
#include <boost/asio.hpp>
#include <boost/threa开发者_如何学God.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.


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

#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
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜