1. 安裝
linux平台下要編譯安裝Boost除gcc和gcc-c++之外,還需要兩個開發庫:
bzip2-devel
和
python-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
. . . . . .
桃花仙人種桃樹,又摘桃花換酒錢_