Chinaunix首页 | 论坛 | 博客
  • 博客访问: 439185
  • 博文数量: 185
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 681
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-06 21:45
个人简介

为梦而战

文章分类

全部博文(185)

文章存档

2016年(3)

2015年(103)

2014年(79)

我的朋友

分类: LINUX

2015-05-20 13:43:49

Boost库是一个经过千锤百炼、可移植、提供源代码的C++库,,作为标准库的后备,是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
#include

int main()
{
  using boost::lexical_cast;
  int a= lexical_cast("123456");
  double b = lexical_cast("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
阅读(949) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~