CentOS下安装boost库

1、首先去www.boost.org网站 下载boost库压缩文件,比如boost_1_64_0.tar.gz或者在SourceForge用 wget 直接下载,网址:

https://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.7z

https://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.gz

2、安装boost依赖包:

yum -y install gcc gcc-c++ python python-devel libicu libicu-devel zlib zlib-devel bzip2 bzip2-devel

若缺少依赖包会提示以下信息:

提示信息【Unicode/ICU support for Boost.Regex?... not found.】,依赖包【 libicu libicu-devel 】
提示信息【error: no command provided, default command 'g++' not found】,依赖包【 gcc-c++ 】
提示信息【- zlib                     : no】,依赖包【 zlib zlib-devel 】
提示信息【- bzip2                    : no】,依赖包【 bzip2 bzip2-devel 】

3、执行命令:tar xvfz boost_1_64_0.tar.gz,解压boost库;

4、进入解压出的boost目录,执行./bootstrap.sh编译boost库;

注意:如果编译失败了,建议" rm -rf boost_1_64_0"之后,重新解压,重新编译。

5、执行./b2 install安装;

6、测试验证:

#include <string>

#include <iostream>

#include <boost/version.hpp>  //包含Boost头文件

#include <boost/config.hpp>   //包含Boost头文件

using namespace std;

int main()

{

    cout << BOOST_VERSION << endl;    //Boost版本号

    cout << BOOST_LIB_VERSION << endl;   //Boost版本号

    cout << BOOST_PLATFORM << endl;    //操作系统

    cout << BOOST_COMPILER << endl;    //编译器

    cout << BOOST_STDLIB << endl;         //标准库

}

然后使用g++编译:

g++ -o boost_test.out boost_test.cpp -I.

运行:

./boost_test.out

结果:

106800

1_68

linux

GNU C++ version 4.8.5

GNU libstdc++ version 20150623

至此boost安装完成。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值