Boost库安装配置

 
下载
1
Boost 库通过SourceForge文件发布系统来发布。点击这里SourceForge下载发布版本。并把它解压倒一个合适的地方。
网站上的Boost发布版本包括所有的库和其他资料。它以ZIPTAR.GZTAR.BZ2的格式存在。以前的版本也可以获得。
.zip 文件
.zip 格式被自由解码器和商业的压缩/存档工具广泛支持。如果还没有.zip文件解码器,可以从拥有支持许多操作系统的版本的Info-ZIP网站下载。
每个库的开发者都在.zip文件中支持文本文件行结束符。这在Windows下工作得很好,而在Unix/Linux下则不然。.tar.gz和.tar.bz2文件在Linux/Unix下能很好的支持行结束符。
.tar.gz 和.tar.bz2文件
.tar.gz 格式在UNIX/Linux平台下被广泛支持。一些Windows压缩/存档工具也能读取它。因为gzip格式存档压缩成一个文件而不是单独的压缩没一个文件,所以.tar.gz文件要比.zip小。
.tar.bz2 格式在UNIX/Linux平台下越来越普及,并且其还被整合到一些tar工具中。这个格式使用了被认为比.tar.gz更好的不同的压缩方法,因而压缩成的文件更小。
文本文件行结束符在.tar.gz和.tar.bz2文件中被转换成新行以便在UNIX/Linux平台下容易使用。
Boost CVS
所有Boost文件,包括实体发行树、网站的HTML文件都用CVS库维护。可以用命令行、GUI(图形用户接口)或者浏览器来访问。
通过命令行或图形客户端访问Boost CVS
可以通过包含从各个GUI和命令行的客户端到主页的链接的SourceForge看到更新过的CVS文件(F部分)
命令行客户端的一般操作程序像这样:
cvs  -d:pserver:anonymous@boost.cvs.sourceforge.net:/cvsroot/boost  login
[
当需要密码的时候按回车 ]
cvs  -z3  -d:pserver:anonymous@boost.cvs.sourceforge.net:/cvsroot/boost  checkout  boost
cvs
  -d:pserver:anonymous@boost.cvs.sourceforge.net:/cvsroot/boost  logout
阅读CVS客户手册获得更多信息。
访问是只读的;如果你是库的作者并且打算已可写方式访问,请和管理员联系。
通过浏览器访问Boost CVS
由CVS的Boostbook生成文件
准备
推荐使用Boost.Build这个Boost编译系统来编译安装Boost库。本说明的剩余部分解释它的用法,但是用与不用这个方法取决于自己。注意,除包含用Boost.Build编译的所有需要的文件外,一些库也包含非Boost.Build makefiles文件和/或工程文件。
2
编译系统使用Boost.Jam这个Perforce Jam的可移植的make的替代品。如果使用Boost发行版本,推荐到SourceForge下载已编译成可执行的Boost.Jam,如果没有为正使用的平台提供或者使用的Boost源文件还处于未发布状态,就需要由源文件编译成bjam,该源文件包含在Boost源文件树里。通过把可执行的bjam文件拷贝到可访问的PATH下来安装。
配置工具
在使用Boost.Build之前,需要配置使用的编译器工具。编译系统的工具集设计成以两种方式中的一种来工作:
1.                              用户用常规的方法为其欲正常使用的每一套编译工具集都设置环境。例如,对于Microsoft VC++,就可以载PATH环境变量中添加“...VC98/Bin”或“...VC98/Bin”, 还需要编译之前调用一次VCVAR32.BAT或者VSVAR32.BAT等等操作。而使用CodeWarrior , 就应该调用cwenv.bat,而且其他的Metrowerks工具/命令行工具也应该在path变量中。 大多数的Unix系统都会预先配置好这些变量而不需要用户来干预。
2.                              如果某个用户不希望设置被弄乱或者一些工具有非标准安装,可以以设置一个指向工具集安装目录的变量,这个变量可以事先在命令行环境变量里面声明,也可以在调用bjam时声明。编译系统用这个变量来定位工具包括必要的安装。在命令行下可以用“-s”参数来设置这个变量。例如:

bjam "-sGCC_ROOT_DIRECTORY=/usr/local/gcc-3.3.2"
一些参数,像工具集的“TOOLS”变量,可以接收多个用空格分开的值。其他的,比如上述的path,也可以用空格来分开值。对于这些环境,要为解释命令使用适当的引用。
支持的工具集
3
面是Boost.Build支持的工具集,要得到配置各工具集的信息,可以点击左栏里它的名字。
 
TOOLS Name
Description
Borland C++
Comeau C++ compiler front-end for non-Windows platforms
Comeau C++ compiler front-end for Windows, using Microsoft Visual C++as a back-end.
cw
Metrowerks CodeWarrior Pro 6.x, 7.x, 8.x, and 9.x command-line tools
Apple Darwin OS hosted GNU GCC
dmc
Digital Mars C++, using the STLport standard library implementation
edg
Edison Design Group compiler front-end (evaluation version)
gcc
GNU GCC on Unix and Cygwin.
GNU GCC on Unix and Cygwin, using the STLport standard library implementation
GNU GCC Cygwin command line compiler tools running in "no-cygwin" mode (produces commercially redistributable objects)
Intel C++ for Windows using the Dinkumware standard library in the Intel-required Microsoft Visual C++ 6 or 7 installation
kcc
KAI C++
GNU GCC and associated tools in MinGW configuration (produces commercially redistributable objects)
GNU GCC and associated tools in MinGW configuration (produces commercially redistributable objects), using the STLport standard library implementation
Microsoft Visual C++ version 6 command-line tools. NOTE; For version 7.x (the .NET series) use the vc7, vc-7_1, or vc-8_0 toolsets below.
Microsoft Visual C++ version 6 command-line tools, using the STLport standard library implementation. NOTE; For version 7.x (the .NET series) use the vc7-stlport or vc-7_1-stlport toolsets below.
SunPRO C++ compiler
Compaq C++ for Tru64 UNIX (versions prior to 6.5)
Compaq C++ Version 6.5 for Tru64 UNIX
IBM Visual Age C++ command-line tools
vc7
Microsoft Visual C++ command-line tools from Visual Studio .NET.
Microsoft Visual C++ command-line tools from Visual Studio .NET + STLPort.
Microsoft Visual C++ command-line tools from Visual Studio .NET 2003.
Microsoft Visual C++ command-line tools from Visual Studio .NET 2003 + STLPort.
Microsoft Visual C++ command-line tools from Visual Studio .NET 2005.
编译和安装
普通编译安装过程由高层编译文件驱动(Jamfile)。
4
首先需要进入下载的Boost发行版的目录。例如:
chdir   boost-1.31.0
默认情况下,Boost将试图编译全部的库并且把库和头文件安装到默认的路径中去。在Unix系统中,默认的路径是“/usr/local”。 而Windows系统则是 “C:/Boost”。会在这些文件夹的“lib”子文件夹下面安装Boost库。而头文件则被安装在“include/boost-1_31”子文件夹下面。它反应出了安装的发布版的版本。
5
调用编译系统来指定用来编译和安装的工具集。比如说GNU/GCC:
bjam   "-sTOOLS=gcc"   install
如果只对编译好的库有兴趣,可以编译这些库并把它们收集在同一个文件夹下而不必安装。
bjam   "-sTOOLS=gcc"   stage
可以通过和GNU风格类似的参数集来控制编译和安装系统。这些命令参数可以用来改变安装目录,不安装某一个库等等。还可以用bjam --help"来查看这些参数概要。命令引用的形式:
bjam   [options...]   [install|stage]
Action
 
none
Only builds the Boost libraries. This lets you do the first part of what the install action normally does without copying the built libraries to the install location.
install
Builds and installs Boost libraries and headers.
stage
Builds the Boost libraries and copies them into a common directory.
Option
 
--help
Shows a short summary of the options and syntax of the command.
-sTOOLS=<toolsets>
The list of tools to compile with. Usually only one is needed.
--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 libraries here.
Default; EPREFIX/lib
--includedir=DIR
Install source headers here. The Boost headers are installed in a version specific "boost-<version>" subdirectory in this directory.
Default; PREFIX/include
--builddir=DIR
Build in this location instead of building within the distribution tree. This moves where the sources for the libraries are compiled to before they are installed. Recommended!
--stagedir=DIR
When staging only, with the "stage" action, copy to the given location.
Default; ./stage
--without-<library>
Do not build, stage, or install the specified library.
--with-<library>
Build, stage, or install the specified library. This changes the default from trying to build all possible libraries, to only building the specified libraries.
--with-python-root[=PYTHON_ROOT]
Build Boost.Python libraries with the Python devel packages located at PYTHON_ROOT. The Boost.Python libraries are built only if the build can find the Python development package at this location.
Default; C:/Python24 on Win32.
Default; /usr on Unix, Linux, Cygwin, etc.
--with-python-version[=2.4]
Build Boost.Python libraries with the Python version indicated.
Default; 2.4.
--with-pydebug
Build Boost.Python libraries using the Python debug runtime. This builds an additional set of libraries for use with the debug version of Python. The regular versions of the Boost.Python libraries are also built.
-sHAVE_ICU=1
Build Boost.Regex libraries with Unicode support provided by the ICU libraries. ICU must have been built with the same compiler that you are using to build Boost, and must be installed into your compiler's include and library search paths. See the Boost.Regex installation documentation for more information.
-sICU_PATH=path
Build Boost.Regex libraries with Unicode support provided by the ICU libraries. ICU must have been built with the same compiler that you are using to build Boost, and must have been built (or installed to) directory path. For example if you configured ICU with --prefix=/usr/local/icu/3.3, then use -sICU_PATH=/usr/local/icu/3.3. See the Boost.Regex installation documentation for more information.
-sNO_COMPRESSION=1
Build Boost.Iostreams without support for the compression filters which rely on the non-Boost libraries zlib and libbz2. If you use Windows, this option is enabled by default. If you use UNIX, the compression filters will likely work with no configuration, so this option should not be necessary. For full details see Boost.Iostreams Installation.
有一些Boost.BuildBoost.Jam支持的附加参数。其中最重要的可能就是允许你覆盖默认的编译的"-sBUILD=<features/variants>"参数。参数值"<features/variants>"是一个在编译请求时可以用用空格分隔参数的列表。特征以一个标签和一个或多个值的方式出现;变量则是特征选择的一个简单符号名字。例如默认的编译请求是"debug release <runtime-link>static/dynamic <threading>single/multi",其中"debug" 和 "release"就是变量,余下的每一个特征都会带有这两个变量。
生成物
编译后的生成物以下列形式存在:静态库、动态库。而且不同的平台库的名称也不一样。单个Boost库默认编译后将会产生八个不同的库。例如Boost.Datetime库在Unix类系统下面将会生成:
1.                              libboost_date_time-gcc-d-1_31.so
2.                              libboost_date_time-gcc-mt-d-1_31.so
3.                              libboost_date_time-gcc-1_31.so
4.                              libboost_date_time-gcc-mt-1_31.so
5.                              libboost_date_time-gcc-d-1_31.a
6.                              libboost_date_time-gcc-mt-d-1_31.a
7.                              libboost_date_time-gcc-1_31.a
8.                              libboost_date_time-gcc-mt-1_31.a
·库前缀
 
 
lib
·库名
 
boost_date_time
·工具集
 
-
gcc
·线程
 
-
mt
·实时模式
 
-
d
·Boost版本
-
1_31
·库类型
.a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
库前缀
许多平台要求库具有“lib”前缀,例如Unix,其他的例如在Winodws运行的GCC。因此在所有的Unix类型系统上使用的的Boost库和Windows上使用的Boost静态库前面都会被加上这个前缀。因此Unix下的Boost共享库和windows下的Boost静态库则被分别命名为:
·                                 lib*.so
·                                 lib*.a
而Windows系统的共享库则没有这个前缀来区别动态库和静态库。因此在Windows下面库被命名为:
*.dll
动态库版本
*.lib
Dll 导入库
lib*.lib
静态库版本
库名
Boost 库会在名字中加入“boost_”前缀来区别系统上其他的库。
工具集
编译器名基于用来编译的编译器的缩写。它是由编译器的名称的缩写(2-4个字符)和该编译器的大小版本号(如果存在小版本号)组成的。例如,如果你的编译器是“gcc-3_2_3” 那么编译器的标号就会是“gcc32”。各个编译器的缩写如下:
TOOLS Name
Abbreviation
bcb
como
como
cw
cw
osx
dmc
dmc
dmc
edg
edg
gcc
gcc
gcc
gcc
il
iw
kcc
kcc
bck
mgw
mgw
mp
vc
vc
sw
tru
tru
xlc
vc7
vc
vc
vc
vc
vc
Others
The first part of the toolset name.
线程
这个标签指出编译出来的这个库是否有线程支持。如果支持多线程,就加上“-mt”,反之则不加。
实时模式
这是指出了编译好的库的实时类型和编译好的代码类型。基本上对代码中使用的ABI进行了编码。每一个运行时系统特征和代码编译参数都通过在标签中加入一个字母来表示。
Key
Feature
s
Static link to runtime.
g
Debug runtime.
y
Debug Python system.
d
Debug enabled code.
p
STLport runtime, instead of the vendor toolset runtime.
n
STLport runtime using the "native" IO streams instead of the STLport IO streams.
例如,如果用本地的IO流为STLport来编译一个调试代码模的库,静态链接到调试实时模式,那么这个库的实时标签就是“-sgdpn”。
Boost 版本
这是作为Boost库的版本号的简短标签。由主版本号和副版本号中间加上一个下划线组成。例如1.31.0版会被标记成“-1_31”。为了补全版本信息也会加上补丁号,例如1.31.1版会被标记成“-1_31_1”。
库类型
扩展名标识了库的类型,这依据平台需求。在windows平台上共享库是“.dll” ,静态库包括导入库则是“.lib”。在Unix平台上,静态库(存档)是“.a”,共享库则是“.so”。Unix平台支持的工具器集会有符号链接的全版本扩展名(如“.so.1.31.0”)的库。
在Windows下自动链接
因为大部分Boost库拥有独立的源代码,所以引入对应的库的头文件可以使正确的编译变量自动链接。对于这种工作特性而言,编译器必须支持#pragma comment(lib, name)特性(Microsoft Visual C++、Intel C++、Metrowerks C++和Borland C++都支持)。
如果链接到动态运行库,那么可以选择链接到一个静态或动态的Boost库,默认是静态链接。可以通过为某个特定的库Boost库定义 BOOST_WHATEVER_DYN_LINK宏强制它改变为动态链接。或者,可以通过定义BOOST_ALL_DYN_LINK宏来强制所有的Boost库为动态链接。
可以通过定义BOOST_WHATEVER_NO_LIB宏来强制关闭某个库的这个特性,或者定义BOOST_ALL_NO_LIB宏来关闭所以库的这个特性。
如果想看库的链接情况,可以通过定义 BOOST_LIB_DIAGNOSTIC宏的方式来使得自动链接的代码在每次选作链接的时候产生一个#pragma信息。
这里有一些Boost库(Boost.Test就是一例)因为技术原因是不支持自动链接:请查阅所使用的库的每个文档来获取更多的信息,并且Boost.Config文档提供了更多的配置宏的信息。下面的表格显示了当前支持的配置(只有头文件的库没有列在这里):
Library
Static Link
Dynamic Link
Default linkage
Automatic library selection
Comments
Date-Time
Yes
Yes
static
Yes
 
Filesystem
Yes
Yes
static
Yes
 
Graph
Yes
No
static
No
The separate Graph library source is needed only when reading an AT&T graphviz file.
Iostreams
Yes
Yes
static
Yes
 
Program Options
Yes
Yes
static
Yes
 
Python
Yes
Yes
dynamic
No
Since all Python extensions are DLL's it makes sense to dynamic link to the Boost Python library by default (static linking is only really an option if you are embedding python).
Regex
Yes
Yes
static
Yes
 
Serialization
Yes
Yes
static
Yes
 
Signals
Yes
Yes
static
Yes
 
Test
Yes
No
static
No
Which library you link to depends upon which program entry point you define, rather than which Boost.Test features you use.
Thread
Partial
Yes
static (Visual C++), otherwise dynamic
Yes
For technical reasons static linking is supported on only one Windows compiler (Visual C++).
Wave
Yes
Yes
static
Yes
 
其他步骤
根据平台和配置,可能还需要一些其他配置来编译和安装Boost。
·                                 配置Boost源代码 。在大多数平台下都不需要这一步,但是如果打算在Boost没有测试过或不支持的平台下编译Boost,这可能是必须的。
·                                 如果Boost.Build在检测你的Python的安装时出了问题,那么它会打印出一条怎样配置才能找到Python的安装的短消息。看这些详细说明可以获得更多的信息。

Revised $Date: 2006/05/15 23:47:28 $
Copyright © Rene Rivera 2003.
Copyright
© Jens Maurer 2001.
Copyright
© John Maddock 2004.
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值