您的位置:首页 > 其它

Windows下Boost库安装方法

2016-03-18 16:05 465 查看
1. 概述

最近打算学习一下Boost库,这里记录一下Boost库的安装的方法,IDE涉及DEV C++和VS 2008。

2. 下载

直接下载链接:参见网页 http://www.boost.org/users/history/version_1_46_1.html,这里的链接网速很慢,78MB的东西,下载了10%左右,就定住了,试了三次都是这样,基本放弃了这个下载链接。
SVN下载链接,文件保存在“D:\Boost”下:参见网页 http://www.boost.org/users/download/,有一定速度,下载使用了49分钟,传了115.99MB,版本为1.47,我看了下下载的文件夹,吓了我一跳:文件夹大小501MB,占用空间3.15GB。赶紧去网上查了下,有的人说对于1.46版本的Boost,如果完全编译后,可能需要12-15GB的空间,这样就不奇怪了,虽然还没编译就占了3GB。
3. VS2008 Boost库编译(-vc9)

首先,编译bjam,在命令行下,运行bootstrap.bat -vc9

然后,编译库。在命令行下,运行:

bjam stage --toolset=msvc-9.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="D:\Boost\bin\vc9" link=static runtime-link=shared threading=multi debug release

bjam stage --toolset=msvc-9.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="D:\Boost\bin\vc9" link=static runtime-link=static threading=multi debug release

编译用了50分钟左右,产生了303MB的文件。

4. VS2008 Boost库配置

Tools -> Options -> Projects and Solutions -> VC++ Directories

在Library files中,增加D:\Boost\bin\vc9\lib

在Include files中,增加D:\Boost\

其中,Library的目录就是前面编译产生的那些库文件保存到的位置

  其中,Include的目录随着Boost的不同版本会不同,现在1.47版本只要指定为D:\Boost即使用SVN下载Boost的文件夹就可以了。

5. VS2008 Boost库测试


View Code
6. DEV C++ Boost库编译

首先,设置gcc的环境变量。在我的电脑上点击右键,选择Properties菜单项。然后在弹出的对话框中选择Advanced页,点击Environment Variables按钮。之后进行如下设置,选择PATH,然后点击Edit按钮,在最后加上DEV-C++编译器的路径,如C:\Program Files\DEV-CPP\Bin,路径之间用分号分隔。 设置完毕点击OK按钮保存。

然后,编译bjam,运行bootstrap.bat -gcc

接着,编译boost库:

bjam stage --toolset=gcc --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="D:\Boost\bin\gcc" link=static runtime-link=shared threading=multi debug release

bjam stage --toolset=gcc --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="D:\Boost\bin\gcc" link=static runtime-link=static threading=multi debug release

7. DEV C++ Boost库配置

在Toos->Compiler Options->Directories->C++ Include中,增加D:\Boost

8. DEV C++ Boost库测试

第一种,只要包含该头文件即可,就能使用该头文件中的所有函数。


View Code
第二种,需要建立一个project,而不能只是编译单个的c++文件,因为在dev c++中,只有在project中才能设置linker的参数。 建立project后,“Project"-->"Project Options"-->"Parameters"选项卡--->在linker框中添加:"-lboost_regex-mt",告诉linker在链接的时候,链接regex库。


View Code
9. 参考文献

Boost下载安装编译配置使用指南(含Windows和Linux) http://kb.cnblogs.com/a/1485890/
VS2008中编译Boost 1.38 http://blog.csdn.net/wrx_2009/archive/2009/06/04/4242841.aspx
VS2008 Team System 安装Boost库 http://www.cookbus.com/show-121-1.html
boost在DevC++中的安装过程 http://blog.csdn.net/suwei19870312/archive/2011/03/13/6246400.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: