文|Seraph
一 下载
-
首先从Boost下载官网下载源码,当然你也可以下载编译好的库文件直接用。
我下载的是boost_1_68_0.zip
-
解压到某个目录下,我解压到了D盘根目录:E:\boost_1_68_0
二 编译源码
- 生成bjam.exe可执行文件
- 用VS2010(VS2017)命令行工具进入到目录E:\boost_1_68_0,输入
booststrap.bat
- 在目录E:\boost_1_68_0下会生成b2.exe、bjam.exe、project-config.jam文件。
- 用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
) - 可以单独提取下面两个文件夹使用,其他文件仅是编译时需要
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
三 新建测试工程
- 新建TestBoost工程(Win32 Console)
- 将lib路径和include路径添加到工程属性
- 输入如下测试代码
#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;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)