VS2010(VS2017)+Boost_1_68_0环境搭建

文|Seraph

一 下载
  1. 首先从Boost下载官网下载源码,当然你也可以下载编译好的库文件直接用。
    我下载的是boost_1_68_0.zip

  2. 解压到某个目录下,我解压到了D盘根目录:E:\boost_1_68_0

二 编译源码
  1. 生成bjam.exe可执行文件
  • 用VS2010(VS2017)命令行工具进入到目录E:\boost_1_68_0,输入booststrap.bat
  • 在目录E:\boost_1_68_0下会生成b2.exe、bjam.exe、project-config.jam文件。
  1. 用bjam.exe编译
    输入如下命令:
    bjam stage --toolset=msvc-10.0 --build-type=complete --stagedir="E:\boost_1_68_0\bin\vc10" link=static runtime-link=shared threading=multi debug release
    (VS2017:bjam stage --toolset=msvc-14.1 --build-type=complete --stagedir="E:\boost_1_68_0\bin\vc14" link=static runtime-link=shared threading=multi debug release
  2. 可以单独提取下面两个文件夹使用,其他文件仅是编译时需要
    lib路径:E:\boost_1_68_0\bin\vc10\lib(VS2017:E:\boost_1_68_0\bin\vc14\lib)
    include路径:E:\boost_1_68_0\boost
三 新建测试工程
  1. 新建TestBoost工程(Win32 Console)
  2. 将lib路径和include路径添加到工程属性
  3. 输入如下测试代码
#include "stdafx.h"
#include <iostream>
#include "thread.hpp"  
using namespace std;

void thread_func()
{
	cout << "This is my first boost,thread function test" << endl;
}

int _tmain(int argc, _TCHAR* argv[])
{
	boost::function<void()> func(thread_func);
	boost::thread t(func);
	t.join();
	return 0;
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值