1、解压
tar -xzvf boost_1_44_0.tar.gz 解压后319M
2、根据安装路径生成jam文件
[root@docong boost_1_44_0]# ./bootstrap.sh --prefix=/home/boostInstall
3、安装
./bjam install
编译之后 94M,编译时间30分钟左右。
4、设置环境变量
4、验证
测试文件是lex.cpp:
#include < boost / lexical_cast.hpp >
#include < iostream >
int main()
{
using boost::lexical_cast;
int a = lexical_cast<int>("123");
double b = lexical_cast<double>("123.12");
std::cout<<a<<std::endl;
std::cout<<b<<std::endl;
return 0;
}
编译:
g++ lex.cpp -I$BOOST_ROOT -o lex
运行:
./lex
输出:
123
123.12