CentOS7 安装boost

(1)到这个网址www.boost.org下载相应的代码包,我下载的是目前最新的版本boost_1_59_0.tar.bz2
(2)进入目录执行解压操作:tar -jxvf boost_1_59_0.tar.bz2
执行命令 ./bootstrap.sh 生成安装工具bjam和b2
(3)这里利用b2工具进行安装,可以使用./b2 –help 查看命令选项
(4)准备安装boost库
执行命令 ./b2 install进行安装,默认是安装boost所有内容,也可以使用./bootstrap.sh –with-libraries=system,filesystem,log,thread 进行选择
安装完毕后的头文件默认是在/usr/local/include目录下,.a和.so在/usr/local/lib目录下。
然后将需要使用的库sudo cp至/usr/lib 。不然在执行代码时,ldd会提示找不到.so文件。
下面写个小程序看看能不能用boost库里面的东西

/*
 * lcw.cpp
 *  start from the very beginning,and to create greatness
 *  @author: Chuangwei Lin
 *  @E-mail:979951191@qq.com
 *  @date:2015年8月22日  下午5:15:07
 *  @brief:
 */
#include <iostream>
#include <boost/tuple/tuple.hpp>
int main()
{
    using namespace std;
    int i;
    char c;
    double d;
    boost::tuples::tie(i,c,d);
    boost::tuples::tie(i,c,d) = boost::tuples::tuple <int,char,double>(1,'A',0.68);
    cout << d <<endl;
}

编译正常通过,运行得到如下的结果:
这里写图片描述
说明boost应该是安装成功了。

posted @ 2015-08-23 22:46  sigma0  阅读(1011)  评论(0编辑  收藏  举报