解压boost到/root/icas/boost/boost_1_38_0下,拷贝bjam到此文件夹,
注: 词句的prefix选项没起到作用,/usr/include下没有创建boost文件夹,待查!
[root@localhost boost_1_38_0]# ./bjam --prefix=/usr/include --with-system --with-thread --with-date_time --with-regex --with-serialization stage
创建timer.cpp:
#include
#include
#include
int main()
{
boost::asio::io_service io;
boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
t.wait();
std::cout << "Hello, world!\n";
return 0;
}
[root@localhost tmp]# g++ -I /root/icas/boost/boost_1_38_0 timer.cpp -L/root/icas/boost/boost_1_38_0/stage/lib/ -lboost_system-gcc41-mt-1_38 -lboost_thread-gcc41-mt-1_38
[root@localhost tmp]# ./a.out
./a.out: error while loading shared libraries: libboost_system-gcc41-mt-1_38.so.1.38.0: cannot open shared object file: No such file or directory
说明未设置环境变量
[root@localhost tmp]# LD_LIBRARY_PATH=/root/icas/boost/boost_1_38_0/stage/lib
[root@localhost tmp]# export LD_LIBRARY_PATH
[root@localhost tmp]# ./a.out
Hello, world!
[root@localhost tmp]#
TODO: 将编译好的lib以及boost头文件都放到/usr/include/boost目录下,避免每次编译都输入路径
阅读(1954) | 评论(0) | 转发(0) |