window vs编译并使用Boost库
2016-10-26 22:43
232 查看
从http://www.boost.org上下载到目前最新的boost库,快速传送门:boost_1_53_0.zip,当然你也可以从http://sourceforge.net/projects/boost/files/boost-jam/这里得到源代码,快速传送门:boost_1_53_0.zip(98.1
MB)
我使用了后者
Boost程序库完全开发指南——深入C++“准”标准库高清PDF版 http://www.linuxidc.com/Linux/2013-07/87574.htm
Ubuntu下编译安装boost库 http://www.linuxidc.com/Linux/2013-07/87573.htm
Ubuntu下编译boost 1.52b http://www.linuxidc.com/Linux/2013-02/79004.htm
Ubuntu编译安装boost并在eclipse C/C++中使用 http://www.linuxidc.com/Linux/2011-04/34790.htm
![](http://www.linuxidc.com/upload/2014_06/140621101081121.jpg)
进入到源代码目录中
![](http://www.linuxidc.com/upload/2014_06/140621101081122.jpg)
指定msvc版本11.0对应的是vs2012,--stagedir是指定编译后存放的目录
bjam stage --toolset=msvc-11.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-Python --without-serialization
--without-wave --stagedir="F:\boost\boost_1_53_0\bin\vc11" link=static runtime-link=shared runtime-link=static threading=multi debug release
稍微等一会,库就编译好了……
vs2010
bjam stage --toolset=msvc-10.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="C:\Users\Administrator\git\essearch\doc\rpc\hprose-cpp-master\boost_1_55_0\bin\vc10" link=static
runtime-link=shared runtime-link=static threading=multi debug release
vs2013
bjam stage --toolset=msvc-12.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-wave --stagedir="G:\boost" link=static runtime-link=shared runtime-link=static threading=multi debug release
首先需要设定文件包含目录:
我的boost库解压在F盘下
![](http://www.linuxidc.com/upload/2014_06/140621101081123.jpg)
设定库目录:
![](http://www.linuxidc.com/upload/2014_06/140621101081124.jpg)
“F:\boost\boost_1_53_0\”是我编译的出来lib的目录
然后建立我们的第一个boost项目,代码如下:
[cpp] view
plain copy
![](https://code.csdn.net/assets/CODE_ico.png)
![](https://code.csdn.net/assets/ico_fork.svg)
#include <boost/thread.hpp>
#include <conio.h>
#include <iostream>
using namespace std;
void mythread()
{
cout << " hello,thread! " << endl;
}
int main(int argc, char* argv[])
{
boost::function<void()> f(mythread);
boost::thread t(f);
t.join();
cout << " thread is over! " << endl;
getch();
}
http://jingyan.baidu.com/article/11c17a2c765763f446e39dc1.html
MB)
我使用了后者
Boost程序库完全开发指南——深入C++“准”标准库高清PDF版 http://www.linuxidc.com/Linux/2013-07/87574.htm
Ubuntu下编译安装boost库 http://www.linuxidc.com/Linux/2013-07/87573.htm
Ubuntu下编译boost 1.52b http://www.linuxidc.com/Linux/2013-02/79004.htm
Ubuntu编译安装boost并在eclipse C/C++中使用 http://www.linuxidc.com/Linux/2011-04/34790.htm
2、得到源代码之后,使用vs2012的cl.exe编译
![](http://www.linuxidc.com/upload/2014_06/140621101081121.jpg)
进入到源代码目录中
3、建立编译工具bjam.exe----需要执行bootstrap.bat
![](http://www.linuxidc.com/upload/2014_06/140621101081122.jpg)
4、指定编译命令
指定msvc版本11.0对应的是vs2012,--stagedir是指定编译后存放的目录bjam stage --toolset=msvc-11.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-Python --without-serialization
--without-wave --stagedir="F:\boost\boost_1_53_0\bin\vc11" link=static runtime-link=shared runtime-link=static threading=multi debug release
稍微等一会,库就编译好了……
vs2010
bjam stage --toolset=msvc-10.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="C:\Users\Administrator\git\essearch\doc\rpc\hprose-cpp-master\boost_1_55_0\bin\vc10" link=static
runtime-link=shared runtime-link=static threading=multi debug release
vs2013
bjam stage --toolset=msvc-12.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-wave --stagedir="G:\boost" link=static runtime-link=shared runtime-link=static threading=multi debug release
5、开始使用boost
首先需要设定文件包含目录:我的boost库解压在F盘下
![](http://www.linuxidc.com/upload/2014_06/140621101081123.jpg)
设定库目录:
![](http://www.linuxidc.com/upload/2014_06/140621101081124.jpg)
“F:\boost\boost_1_53_0\”是我编译的出来lib的目录
然后建立我们的第一个boost项目,代码如下:
[cpp] view
plain copy
![](https://code.csdn.net/assets/CODE_ico.png)
#include <boost/thread.hpp>
#include <conio.h>
#include <iostream>
using namespace std;
void mythread()
{
cout << " hello,thread! " << endl;
}
int main(int argc, char* argv[])
{
boost::function<void()> f(mythread);
boost::thread t(f);
t.join();
cout << " thread is over! " << endl;
getch();
}
http://jingyan.baidu.com/article/11c17a2c765763f446e39dc1.html
相关文章推荐
- ++在VC++.net平台下编译使用boost库的简捷方法
- Boost库通用编译配置使用指南
- 使用android ndk编译boost库
- 编译使用boost库(win7+boost1.53+vs2012)
- 关于Boost库在VS2010下的编译使用
- 在VC++.net平台下编译使用boost库的简捷方法
- boost库使用:vs2013下boost::container::vector编译出错解决
- Linux下G++怎么编译使用Boost库的程序
- Boost库的使用和编译
- Win7_64位系统下,使用VS2010编译stlport库和Boost库
- vc2005 使用Boost库的编译步骤.
- 【转帖】vc2005 使用Boost库的编译步骤.
- 关于Boost库在VS2010下的编译使用(转)
- macos下编译使用boost库
- 关于Boost库在VS2010下的编译使用(转)
- 在VC++.net平台下编译使用boost库的简捷方法
- VS2005 使用Boost库的编译步骤
- windows下使用gcc编译boost库
- c++中使用boost::regex(由于标准库中版本过低,导致不支持多行,需手动编译添加最新版的boost库)
- boost库使用系列3------- boost_1_54_0在Xcode5,IOS模拟器上编译通过