Bootstrap

CentOS下Boost源码编译安装

1. 安装

linux平台下要编译安装Boost除gcc和gcc-c++之外,还需要两个开发库:bzip2-develpython-devel ,因此在安装前应该先保证这两个库已经安装

[root@VM-0-9-centos ~]# yum install bzip2 bzip2-devel bzip2-libs python-devel

执行命令

[root@VM-0-9-centos ~]# cd /home
[root@VM-0-9-centos home]# mkdir boost
[root@VM-0-9-centos home]# cd boost
[root@VM-0-9-centos boost]# wget https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0_rc1.tar.gz
[root@VM-0-9-centos boost]# tar -xvf boost_1_74_0_rc1.tar.gz
[root@VM-0-9-centos boost]# cd boost_1_74_0
[root@VM-0-9-centos boost_1_74_0]# ./bootstrap.sh
[root@VM-0-9-centos boost_1_74_0]# ./b2 install --with=all

2. 测试

新建文件boosttest.cpp, 如下

#include <boost/lexical_cast.hpp>
#include <iostream>
int main()
{
  using boost::lexical_cast;
  int a= lexical_cast<int>("123456");
  double b = lexical_cast<double>("123.456");
  std::cout << a << std::endl;
  std::cout << b << std::endl;
  return 0;
}

执行命令编译

[root@VM-0-9-centos xltest]# g++ -o boosttest boosttest.cpp
./boosttest

执行后输出即配置成功

[root@VM-0-9-centos xltest]# ./boosttest
123456
123.456

4. 可能的问题

如下,

[root@VM-0-9-centos boost_1_74_0]# ./b2 install --with=all
./b2: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./b2)
./b2: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./b2)

解决办法
https://blog.csdn.net/ShyLoneGirl/article/details/109594054

.
.
.
.
.
.


桃花仙人种桃树,又摘桃花换酒钱_

;