win10 64位 vs2015安装boost库
折腾了一晚上,终于把boost库装好了。下面说一下安装方法:
1、下载boost官网安装包。
https://dl.bintray.com/boostorg/release/1.66.0/binaries/
注意:这里一定要选择好boost版本
如: boost_1_66_0-msvc-14.0-64.exe 14.0对应vs2015 64:64位
2、下载后解压。
3、找到 开始->所有程序->visual studio 2015 ->vs2015 x64 本机工具命令提示符 打开。
注意:双击bootstrap.bat生成bjam.exe ,打开bjam.exe 也可以编译,但是最好用vs2015 自带的命令提示符编译。因为最终要在vs2015环境中加载。要选择x64的命令提示符与下载的boost 64位版本对应。
4、切换到刚才的boost解压目录,运行bootstrap.bat,boost根目录下会生成bjam.exe,然后再命令提示符下
输入:
bjam stage --toolset=msvc-14.0 architecture=x86 address-model=64 --without-graph --without-graph_parallel --stagedir="D:\gs\boost_1_66_0\vc14-x64" link=static runtime-link=shared runtime-link=static threading=multi debug release
注意:vc14-x64是自定义的目录,此目录存放编译成功的静态库。
大约不到一个小时,编译完成。
5、最终目录如下:
6、配置boost库:
vs2015 新建项目。然后该项目的属性页:c/c++ 常规 附加包含目录:设置为:D:\gs\boost_1_66_0。
然后 链接器 常规 附加库目录 设置为 D:\gs\boost_1_66_0\vc14-x64\lib
注意还有一点非常重要:要将解决方案平台改成x64
7、这样boost库就配置好了。
测试boost库:
-
#include "stdafx.h"
-
#include<iostream>
-
#include<string>
-
-
#include<boost/thread.hpp>
-
using namespace std;
-
-
void mythread()
-
{
-
cout << " hello,thread! " << endl;
-
}
-
-
int main()
-
{
-
boost::function<void()> f(mythread);
-
boost::thread t(f);
-
t.join();
-
cout << " thread is over! " << endl;
-
-
return 0;
-
}
enjoy it!