1、在这里下载你需要的Boost库(含各个版本哦):http://blog.youkuaiyun.com/duan19920101/article/details/51363418
2、将下载压缩包解压到本地
解压后可看到文件夹下有个bootstrap.bat文件。
3、打开cmd命令窗口,运行bootstra.bat文件(也可直接双击)
执行以下命令,具体根据自己的环境略有变化。
最主要的目的是我们要运行bootstrap.bat文件
然后在文件夹下我们会发现新生成了一个名为b2.exe的文件
4、在cmd窗口中运行b2.exe文件(可直接双击运行)
此过程将默认根据系统已经安装好的编译工具(VS2008,2010,2012,2013,2015)等编译相应的Lib文件、头文件等(一般根据你电脑上的VS的最高版本生成对应的.lib文件)。
至此,Boost库安装完成
5、配置VS2013
新建一个BoostTest工程文件,添加测试代码
#include <boost/lexical_cast.hpp>
#include <iostream>
using namespace std;
int main()
{
using boost::lexical_cast;
int a = lexical_cast<int>("123");
double b = lexical_cast<double>("123.0123456789");
string s0 = lexical_cast<string>(a);
string s1 = lexical_cast<string>(b);
cout << "number: " << a << " " << b << endl;
cout << "string: " << s0 << " " << s1 << endl;
int c = 0;
try{
c = lexical_cast<int>("abcd");
}
catch (boost::bad_lexical_cast& e){
cout << e.what() << endl;
}
return 0;
}
在视图->属性页(VS2013在这才能找到相关的属性配置栏)->C/C++,在 附加包含目录添加或编辑Boost的文件路径,我的是:
D:\软件\C_library\boost_1_55_0
在链接器选项附加库目录下添加Boost库lib文件路径,我的是:D:\软件\C_library\boost_1_55_0\libs
6、测试代码
代码运行成功,说明Boost库一切配置顺利。