Win7下Boost库的安装
Boost库是C++领域公认的经过千锤百炼的知名C++类库,涉及编程中的方方面面,简单记录一下使用时的安装过程
1.boost库的下载
boost库官网主页:www.boost.org
2.安装
将下载的压缩包解压到指定的目录
3.建立编译工具bjam.exe
在源码目录下执行bootstrap.bat,生成bjam.exe
4.在命令行模式下利用bjam编译boost库,这里利用VS2012自带的命令行工具
D:\Program Files\VS2012\VC>cd D:\Program Files\BoostSDK\boost
D:\Program Files\BoostSDK\boost>bjam stage
D:\Program Files\BoostSDK\boost>bjam stage --toolset=msvc-11.0 --without-graph -
-without-graph_parallel --without-mpi --without-wave --stagedir="D:\Program File
s\BoostSDK\bin\vc110" link=static runtime-link=shared runtime-link=static thread
ing=multi debug release
说明:
--toolset 指明编译工具,msvc-11.0表示Visual Studio 2012
--stagedir 指明编译后库文件的存放路径
--without-mpi表示不编译mpi库,其他的--without类似
boost库中有些库是必须要编译才能使用的,大部分只要引用头文件即可,少数是必须编译成二进制文件的。
摘用官方文档的一点说明:
The first thing many people want to know is, “how do I build Boost?” The good news is that often, there's nothing to build.
Nothing to Build?
Most Boost libraries are header-only: they consist entirely of header files containing templates and inline functions, and require no separately-compiled library binaries or special treatment when linking.
The only Boost libraries that must be built separately are:
- Boost.Chrono
- Boost.Context
- Boost.Filesystem
- Boost.GraphParallel
- Boost.IOStreams
- Boost.Locale
- Boost.MPI
- Boost.ProgramOptions
- Boost.Python (see the Boost.Python build documentation before building and installing it)
- Boost.Regex
- Boost.Serialization
- Boost.Signals
- Boost.System
- Boost.Thread
- Boost.Timer
- Boost.Wave
A few libraries have optional separately-compiled binaries:
- Boost.DateTime has a binary component that is only needed if you're using its to_string/from_string or serialization features, or if you're targeting Visual C++ 6.x or Borland.
- Boost.Graph also has a binary component that is only needed if you intend to parse GraphViz files.
- Boost.Math has binary components for the TR1 and C99 cmath functions.
- Boost.Random has a binary component which is only needed if you're using random_device.
- Boost.Test can be used in “header-only” or “separately compiled” mode, although separate compilation is recommended for serious use.
- Boost.Exception provides non-intrusive implementation of exception_ptr for 32-bit _MSC_VER==1310 and _MSC_VER==1400 which requires a separately-compiled binary. This is enabled by #define BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR.
5.安静的等待库的编译完成