编译并使用Boost库(Win7+Boost1.53+VS2012)
2015-08-02 22:34
323 查看
1、下载boost库
从http://www.boost.org上下载到目前最新的boost库,快速传送门:boost_1_53_0.zip,当然你也可以从http://sourceforge.net/projects/boost/files/boost-jam/这里得到源代码,快速传送门:boost_1_53_0.zip(98.1MB)
我使用了后者
Boost程序库完全开发指南——深入C++“准”标准库高清PDF版 http://www.linuxidc.com/Linux/2013-07/87574.htm
Ubuntu下编译安装boost库 http://www.linuxidc.com/Linux/2013-07/87573.htm
Ubuntu下编译boost 1.52b http://www.linuxidc.com/Linux/2013-02/79004.htm
Ubuntu编译安装boost并在eclipse C/C++中使用 http://www.linuxidc.com/Linux/2011-04/34790.htm
2、得到源代码之后,使用vs2012的cl.exe编译
![](http://www.linuxidc.com/upload/2014_06/140621101081121.jpg)
进入到源代码目录中
3、建立编译工具bjam.exe----需要执行bootstrap.bat
![](http://www.linuxidc.com/upload/2014_06/140621101081122.jpg)
4、指定编译命令
指定msvc版本11.0对应的是vs2012,--stagedir是指定编译后存放的目录bjam stage --toolset=msvc-11.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="F:\boost\boost_1_53_0\bin\vc11" link=static runtime-link=shared
runtime-link=static threading=multi debug release
稍微等一会,库就编译好了……
5、开始使用boost
首先需要设定文件包含目录:我的boost库解压在F盘下
![](http://www.linuxidc.com/upload/2014_06/140621101081123.jpg)
设定库目录:
![](http://www.linuxidc.com/upload/2014_06/140621101081124.jpg)
“F:\boost\boost_1_53_0\”是我编译的出来lib的目录
然后建立我们的第一个boost项目,代码如下:
#include "stdafx.h"
#include "boost/thread.hpp"
#include "iostream"
using namespace std;
void mythread()
{
cout << " hello,thread! " << endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
boost::function<void()> f(mythread);
boost::thread t(f);
t.join();
cout << " thread is over! " << endl;
return 0;
}
6.这是输出:
![](http://www.linuxidc.com/upload/2014_06/140621101081125.jpg)
相关文章推荐
- HDU 5333 Undirected Graph LCT+BIT
- 程序设计策略(设计一款APP的步骤)
- c++中的函数重载
- java常识(列表更新中)
- 关于nutch2.x不支持mysql
- (一〇三)静态库(.a)的调试
- POJ 3278 Catch That Cow
- 字符串反转,但单词不倒置
- (一〇三)静态库(.a)的调试
- innodb文件
- CodeForces 149D 区间DP Coloring Brackets
- Jquery绑定事件(bind和live的区别)
- leetcode 077 —— Combinations
- shell内部命令-----变量类
- 杭电acm 1009 FatMouse' Trade 比较典型的贪心问题
- 平面设计入门之快速选择工具
- [题解+总结]NOIP动态规划大合集
- HDU 2196-Computer(树形dp)
- Ansible模块知多少
- const关键字详解