编译并使用boost库(win7+boost1.60+vs2013)

下载boost库

从http://www.boost.org上下载到目前最新的boost库,快速传送门:boost_1_60_0.zip

 

得到源代码之后,使用vs2013的cl.exe编译




进入到源代码目录中


建立编译工具bjam.exe----需要执行bootstrap.bat



指定编译命令

 

指定msvc版本12.0对应的是vs2013--stagedir是指定编译后存放的目录

bjam stage --toolset=msvc-12.0 --without-graph --without-graph_parallel --stagedir="D:\boost\boost_1_60_0\bin\vc12" link=static runtime-link=shared runtime-link=static threading=multi debug release

稍微等一会,库就编译好了……


开始使用boost

首先需要设定文件包含目录:

我的boost库解压在D盘下


设定库目录:


然后建立我们的第一个boost项目,代码如下:

#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;
}

这是输出


  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值