boost安装

1 官方文档
www.boost.org

2 安装
2.1  ubuntu
sudo apt-get install libboost-all-dev

2.2 centos
wget http://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.tar.gz/download
tar -zxvf boost_1_57_0.tar.gz
cd boost_1_57_0

编译(参考 http://blog.csdn.net/hzdiy/article/details/18888477)
./bootstrap.sh --with-libraries=system,filesystem,log,thread --with-toolset=gcc
./b2 toolset=gcc cxxflags="-std=c++11"  

./b2 install --prefix=/usr

3 测试使用
vim  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;
}

编译运行
g++ -o test test.cpp
test  test.cpp
./test
123456
123.456

posted @ 2015-01-04 16:14  谭志宇  阅读(245)  评论(0编辑  收藏  举报