How to compile boost async_client.cpp

2020-01-29 21:00发布

问题:

What is the correct command to compile this code? http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/example/http/client/async_client.cpp I had installed boost library in /usr/include/boost

回答1:

E.g.

clang++ -std=c++03 -Wall -pedantic -g -O2 async_client.cpp -o async_client -lboost_system -lboost_thread -lpthread

Assuming your system's packaged version of Boost (or pre-configured include & lib paths). To make use of your custom built Boost library tree in ~/custom/boost:

clang++ -std=c++03 -Wall -pedantic -g -O2 \
     -isystem ~/custom/boost/ ~/custom/boost/libs/asio/example/cpp03/http/client/ \
     async_client.cpp -o async_client \
     -L ~/custom/boost/stage/lib/ -Wl,-rpath,/home/sehe/custom/boost/stage/lib \
     -lboost_system -lboost_thread -lpthread

Replace clang++ by g++ at will.

-std=c++03 -Wall -pedantic -g -O2 only for expositional purposes.



标签: boost