VS2013下安装Boost库

本文讲解在VS2013中编译和配置Boost库。

1.下载并解压 Boost

到Boost的官网上下载http://www.boost.org/users/history/version_1_60_0.html,这里选择的是最新版的boost


下载后解压到本地目录中,



以管理员身份执行boostrap.bat文件,执行完成之后会生成bjam.exe文件。

2. 编译boost

在命令行中执行bjam.exe程序,此时会根据系统安装的msvc进行编译,



编译过程较长,需要等待一段时间,编译完成之后将会显示如下内容



3. 在项目中使用boost

在VS2013 中新建一个VC++控制台程序的空项目,新建一个mian.cpp文件,在文件中输入以下内容:

#include <boost/lexical_cast.hpp>
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <string>
#include <iterator>
#include <algorithm>
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 << endl;
	cout << "string: " << s0 << endl;
	int c = 0;
	try
	{
		c = lexical_cast<int>("abcd");
	}
	catch (boost::bad_lexical_cast& e)
	{
		cout << e.what() << endl;
	}

	using namespace boost::lambda;
	typedef std::istream_iterator<int> in;

	std::for_each(in(std::cin),in(), std::cout<<(_1*3)<< " ");

	system("pause");
	return 0;
}

在项目属性中配置如下内容:

包含目录添加  G:\boost_1_60_0

库目录添加    G:\boost_1_60_0\stage\lib


执行程序,结果如下:




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值