window 下 vs 2015 想用boost库,window下安装没有ubuntu那么简单,看到一篇博文 完美编译了32位和64位的boost库。转需
原文:https://blog.youkuaiyun.com/zengraoli/article/details/70187556
首先下载得到boost的最新版(目前最新版是1.63)
下载地址:

打开vs的32位命令行工具

进入到boost源代码文件夹中

进入到boost源代码文件夹中

运行bootstrap.bat

执行如下操作,对boost进行编译
(msvc版本14.0对应的是vs2015,--stagedir是指定编译后存放的目录,文章附录有vs版本对应编号)
- bjam stage --toolset=msvc-14.0 --without-graph --without-graph_parallel --stagedir="D:\boost\boost_1_63_0\bin\vc14" link=static runtime-link=shared runtime-link=static threading=multi debug release

进入到boost源代码文件夹中

运行bootstrap.bat

执行如下操作,对boost进行编译
(msvc版本14.0对应的是vs2015,--stagedir是指定编译后存放的目录)
- bjam stage --toolset=msvc-14.0 architecture=x86 address-model=64 --without-graph --without-graph_parallel --stagedir="D:\boost\boost_1_63_0\bin\vc14-x64" link=static runtime-link=shared runtime-link=static threading=multi debug release

这样得到的是就是64位的boot库
设置测试的程序为64位

设置附加的包含路径(下载之后解压的boost文件夹):

设定库路径:

然后建立第一个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;
- }
得到输出
