2.解压到zip到磁盘中,如我解压在D盘中,D:\boost_1_61_0
3.编译
1.利用vs的命令行参数,进入源码解压的目录文件夹中
2.修改user-config.jam中mcvs的版本号,如vs2010 修改为vc10
3.在命令行工具中运行D:\boost_1_61_0>bootstrap.bat,此时会得到b2.exe 和 bjam.exe两个文件,这两个文件其实是一样的,只是bjam.exe使用于老版本
4.在命令行中直接运行.\b2,然后等待编译完成即可
5.使用
编译成功后会有下面的提示,提示你应该怎么使用编译好的库
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
D:\boost_1_61_0
The following directory should be added to linker library paths:
D:\boost_1_61_0\stage\lib
下面是一个小例子,可以看该库是否编译成功
#include "boost/thread.hpp"
#include <iostream>
using namespace std;
void BoostThread()
{
for(int i = 0; i < 10; i ++)
{
cout<<"hello boost "<<i<<endl;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
boost::function<void()> f(BoostThread);
boost::thread t(f);
t.join();
cout<<"thread is over"<<endl;
return 0;
}