参考资料:http://www.pin5i.com/showtopic-24150.html
http://blog.csdn.net/zhuzongwei1988/archive/2010/05/06/5564321.aspx
1. 下载
从http://www.boost.org/ 下载boost库和jam(自己编译也可)
2.安装
将boost安装包解压至本地目录,如:D:/boost_1_45_0,然后将bjam.exe拷贝到该目录下(bjam必须与boost-build.jam在同级目录)。
3.编译
需要打开命令提示符(cmd.exe)窗口并执行bjam,将命令行切换到存放boost库的目录下,输入命令:bjam stage(网上的参考资料说要带参数运行,但是带参数的一直提示参数错误,导致编译失败,所以先不带参数直接编译),编译出来的库就会放在boost库的目录下。
编译总共花了半小时不到的时间,编出来的库存放在D:/boost_1_45_0/stage/lib中,总共是88个文件,大小有800M,(文件数量不一定准确,因为编译的时候,有一部分是编译失败的)加上编译产生的bin.v2(749M)文件夹,现在整个boost_1_45_0文件夹占用2.55G的空间。
再用带参数的命令编译可以得到的一个lib文件夹(44个.lib文件,259M)。编译时用到了之前编译出来的bin.v2文件夹里的内容。
常用编译示例:bjam stage --toolset=msvc-8.0 --without-python --stagedir="D:/boost_1_45_0/vc8" link=static runtime-link=static threading=multi release
编译模式:stage(只生成库) 环境vc8 系统没装python 其它库都编译 stagedir:编译后的库所在目录 boost和c++都动态链接 多线程版本 release版本
vc8/lib中的库和stage/lib中的库,名字是很类似的,只是差一个s,但是在VS工程中,用的是vc8/lib中的库。
如果直接编译带参数的命令可以成功的话,就不需要先编译不带参数的,毕竟800M也是不小的空间的。
4. 使用
把include和lib文件夹包含到查找文件夹中(头文件就在原先解压缩出来的boost文件夹中)。
或者在VS2005中,选“选项”--“项目和解决方案”--“VC++目录”,把库和头文件包含进去。
--------------------------------------
bjam 命令说明
Boost.Build V2 (Milestone 12)
Boost.Jam 03.1.16
Project-specific help:
Project has jamfile at Jamroot
Usage:
bjam [options] [properties] [install|stage]
Builds and installs Boost.
Targets and Related Options:
install Install headers and compiled library files to the
======= configured locations (below).
--prefix=<PREFIX> Install architecture independent files here.
Default; C:/Boost on Win32
Default; /usr/local on Unix. Linux, etc.
--exec-prefix=<EPREFIX> Install architecture dependent files here.
Default; <PREFIX>
--libdir=<DIR> Install library files here.
Default; <EPREFIX>/lib
--includedir=<HDRDIR> Install header files here.
Default; <PREFIX>/include
stage Build and install only compiled library files
===== to the stage directory.
--stagedir=<STAGEDIR> Install library files here
Default; ./stage
Other Options:
--build-type=<type> Build the specified pre-defined set of variations
of the libraries. Note, that which variants get
built depends on what each library supports.
minimal (default) - Builds the single
"release" version of the libraries. This
release corresponds to specifying:
"release <threading>multi <link>shared
<link>static <runtime-link>shared" as the
Boost.Build variant to build.
complete - Attempts to build all possible
variations.
--build-dir=DIR Build in this location instead of building
within the distribution tree. Recommended!
--show-libraries Displays the list of Boost libraries that require
build and installation steps, then exit.
--layout=<layout> Determines whether to choose library names
and header locations such that multiple
versions of Boost or multiple compilers can
be used on the same system.
versioned (default) - Names of boost
binaries include the Boost version
number and the name and version of the
compiler. Boost headers are installed
in a subdirectory of <HDRDIR> whose
name contains the Boost version
number.
system - Binaries names do not include
the Boost version number or the name
and version number of the compiler.
Boost headers are installed directly
into <HDRDIR>. This option is
intended for system integrators who
are building distribution packages.
--buildid=ID Adds the specified ID to the name of built
libraries. The default is to not add anything.
--help This message.
--with-<library> Build and install the specified <library>
If this option is used, only libraries
specified using this option will be built.
--without-<library> Do not build, stage, or install the specified
<library>. By default, all libraries are built.
Properties:
toolset=toolset Indicates the toolset to build with.
variant=debug|release Select the build variant
link=static|shared Whether to build static or shared libraries
threading=single|multi Whether to build single or multithreaded binaries
runtime-link=static|shared
Whether to link to static or shared C and C++ runtime.