当前位置: 移动技术网 > 网络运营>服务器>Linux > linux下安装boost库的完整步骤记录

linux下安装boost库的完整步骤记录

2019年04月17日  | 移动技术网网络运营  | 我要评论

前言

boost库是一个可移植、提供源代码的c++库,作为标准库的后备,是c++标准化进程的开发引擎之一。 boost库由c++标准委员会库工作组成员发起,其中有些内容有望成为下一代c++标准库内容。在c++社区中影响甚大,是不折不扣的“准”标准库。boost由于其对跨平台的强调,对标准c++的强调,与编写平台无关。

在linux安装过程如下:

去官方网站下载最新的: or

一,最简单的方法:

apt-cache search boost

搜到所有的boost库

然后:

sudo apt-get install libboost-all-dev

安装相应的库

二,编译安装,

你需要到官方网站下载最新的版本,最新已经到1.47.0了

1.下载后解压到/opt/boost_1_47_0

2.解决依赖关系 sudo apt-get install python-dev gccxml

如果还不全,就用apt-cache depends xxxxxxx查去

3.编译bjam:

 #cd /opt/boost_1_47_0
 #sudo ./bootstrap.sh

   编译成功

4.编译boost

 #sudo ./bjam

  开始编译

  大约要个十几分钟

  编译完成后:

the boost c++ libraries were successfully built!
the following directory should be added to compiler include paths:
 /home/terry/local/boost_1_47_0
the following directory should be added to linker library paths:
 /home/terry/local/boost_1_47_0/stage/lib

因为我是解压到/home/terry/local/boost_1_46_1下了

所以编译完了是这样的

5.update动态链接库:

sudo ldconfig

安装完毕

三,测试使用:

1.测试代码

#cat test.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;
}

2.编译,运行

--g++ -o test test.cpp
#ls
test test.cpp
# ./test 
123456
123.456

总结:

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对移动技术网的支持。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网