网上有很多安装方法,以下是我成功安装的步骤
1.下载boost_1_34_1压缩文件,解压缩到d:\boost_1_34_1\目录下
2.编译bjam
从vs2005的工具菜单进入命令提示窗口(一定要从这进),cd到d:\boost_1_34_1\tools\jam\src下执行build.bat,会在d:\boost_1_34_1\tools\jam\src\bin.ntx86\產生bjam.exe,將bjam.exe複製到d:\boost_1_34_1\下。
3.设定编译环境
修改user-config.jam (d:\boost_1_34_1\tools\build\v2\user-config.jam) 的MSVC configuration






这里disable了4819警告,这个警告说什么cpp未使用Unicode总之很烦人。如果想disable其他警告也可以依次加在后面。
4.编译boost
bjam --without-python --toolset=msvc-9.0
參數說明
--without-python 表示不使用 python
--toolset : 所使用compiler,Visual Studio 2005為msvc-8.0
--prefix:指定編譯後library的安裝目錄
在Library files加上d:\boost\lib
在Include files加上d:\boost\include\boost-1_34_1
另如果需要用其他库编译成完全完整的,如下
一。下载
boost库2008年3月底发布了1.35.0版本,包括了12个新的库和若干对于新库的修正。请参见http://www.boost.org/users/news/version_1_35_0来获取详细的更新信息。
最大的喜讯就是提供了对于Visual Studio 2008编译器的支持(1.34也可以,但是需要手工修改)。
boost JAM可以不用下载,源代码已经包括在boost库中,可以直接来编译出来。
二。准备工作
编译boost库之前,需要做一些准备工作。下载一些Open Source的包,来支持boost特定库的需要。
1. ICU
ICU提供了unicode和国际化支持,目前的版本是3.8.1。ICU的主页是http://www.icu-project.org/。
(1). 下载
可以从http://www.icu-project.org/download/3.8.html下载源代码版本和使用VS2005编译的版本。推荐下载源代码版本自己进行编译,以避免依赖于VS2005的运行时库。
(2). 编译
ICU的编译比较简单,打开ICU源代码目录下的source\allinone\allinone.sln,需要转换到VS2008格式,直接转换即可。然后,选择release,Rebuild Solution即可。
(3). 测试
将编译出来的bin目录加入到系统的PATH目录中去。然后,重新打开allinone.sln工程。
需要通过测试的项目
- cintltst项目
- intltest项目
- iotest
分别设置成启动项目,运行即可。
2. bzip
bzip的主页是 http://www.bzip.org/,从http://www.bzip.org/downloads.html下面下载源代码包即可,boost直接使用源代码来进行编译。
3. zlib
zlib的主页是http://www.zlib.net/,从该网页下面下载源代码包即可,boost直接使用源代码来进行编译。
4. python
python的主页是http://www.python.org/,下载python的2.5.2版本,安装即可。boost默认是会编译python,并且会自动寻找python的安装目录。
三。编译
到开始菜单的VS2008菜单项下,启动Visual Studio 2008 Command Prompt,以下编译步骤均假定直接在该工具下进行编译。
1. 编译jam
到tools\jam目录下面运行build_dist.bat,编译好的放在tools\jam\stage\boost-jam-3.1.16-1-ntx86目录下,将bjam.exe复制到boost的根目录。
2. 编译boost
鉴于参考2下使用build-type有问题,可以使用以下命令来分别编译dll版本和lib版本。下面是一个示例脚本的例子,其中的目录需要替换:
1
REM used with iostream library
2REM boost_1_35_0\libs\iostreams\doc\installation.html
3
4set BZIP2_SOURCE="E:\library\bzip2-1.0.4"
5set ZLIB_SOURCE="E:\library\zlib123"
6
7REM used with regex library with unicode support
8set ICU_PATH="E:\library\icu"
9
10REM DLL版本
11bjam --toolset=msvc --stagedir=./lib_x86 --builddir=./ address-model=32 link=shared runtime-link=shared threading=multi stage debug release
12
13REM lib版本
14bjam --toolset=msvc --stagedir=./lib_x86 --builddir=./ address-model=32 link=static runtime-link=shared threading=multi stage debug release
15
编译好的文件放置在boost根目录的lib_x86\lib目录下,在boost根目录下的bin.v2目录是中间文件,编译后删除即可。
然后再参考文章最开头的设置即可。