安装(以1.57为例子):
https://www.boost.org OR Boost C++ Libraries - Browse /boost at SourceForge.net下载
1. 解压后
cd boost_1_57_0
./bootstrap.sh
./b2 link=shared
sudo ./b2 install
2.然后在/etc/profile.d目录下
cd /etc/profile.d
sudo vim boost.sh
3.写入 然后 保存
#!/bin/sh
BOOST_ROOT=压缩包的安装路径( pwd )
BOOST_INCLUDE=/usr/local/include/boost
BOOST_LIB=/usr/local/lib
export BOOST_INCLUDE BOOST_LIB BOOST_ROOT
4.执行boost.sh
chmod +x boost.sh
source ./boost.sh
5.测试 vim boost_test.cpp 写入
#include <boost/lexical_cast.hpp>
#include <iostream>
#include <boost/version.hpp>
#include <boost/config.hpp>
int main()
{
using boost::lexical_cast;
int a= lexical_cast<int>("888888");
double b = lexical_cast<double>("888.888");
std::cout << a << std::endl;
std::cout << b << std::endl;
std::cout << BOOST_VERSION << std::endl;
return 0;
}
结果
888888
888.888
105700
卸载:头文件在目录/usr/local/include,而库文件在目录/usr/local/lib 卸载即可
sudo rm -r /usr/local/include/boost
sudo rm -r /usr/local/lib/libboost*
NOTE:/usr/local/lib目录下有cmake 文件,如果是想删除干净需要把cmake文件也删除。不然安装新的boost会导致,编译指向错误。