VS2013下安装Boost库
2016-04-04 15:09
337 查看
本文讲解在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
执行程序,结果如下:
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
执行程序,结果如下:
相关文章推荐
- LeetCodet题解--15. 3Sum
- 对象拷贝类PropertyUtils,BeanUtils,BeanCopier的技术沉淀
- Java接口RandomAccess
- 猜数字(c语言实现)
- Codeforces Round #346 (Div. 2) G. Fence Divercity dp
- Git push错误non-fast-forward后的冲突解决
- A. Dreamoon and Stairs(Codeforces Round #272)
- QPainter 使用注意事项
- POJ 1966 Cable TV Network 最小割
- 爬虫
- 【BZOJ 3531】【SDOI 2014】旅行
- 第四周总结
- flex弹性布局学习笔记
- shell 常用命令语法简介
- Hbase笔记(不全面)
- android开发实用代码片段集合(更新ing)
- httpclient在并发量较高的调用下问题如何去解决
- 数据流重定向
- Tiny4412 烧写uboot到emmc步骤
- 链表1