boost库编译安装调试

1、下载boost库(git repo和下面的不一样)

2、解压

3、在解压后的目录执行bootstrap.sh,生成配置文件

4、执行bjam(b2) ,bjam填上自己的参数,我的参数如下

./bjam install threading=multi release --without-fiber --without-graph --without-graph_parallel --without-math --without-mpi --without-program_options --without-python --without-test --without-wave --prefix=/home/burning/boost

 

5、等30分钟后,编译完成,可以在/home/burning/目录下面看到生成的头文件和库文件

6、配置ld.so.conf, 在/etc/ld.so.cond.d/文件夹下面新建一个文件boost.conf,然后把"/home/burning/boost/lib/"添加到boost.conf中,sudo ldconfig。这一步配置为了防止运行时找不到动态库

7、写个程序测试一下

#include "boost/thread/thread.hpp"
#include <iostream>

void hello()
{
        std::cout <<
        "Hello world, I''m a thread!"
        << std::endl;
}

int main(int argc, char* argv[])
{
        boost::thread thrd(&hello);
        thrd.join();
        return 0;
}
g++ -o thread -g thread.cpp -I /home/burning/boost/include/boost -L /home/burning/boost/lib -lboost_system -lboost_thread

然后就生成可执行程序,运行结果如下

➜  workspace ./thread 
Hello world, I''m a thread!
➜  workspace

 

转载于:https://my.oschina.net/mskk/blog/1550903

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值