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
精彩评论