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:
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.安靜的等待庫的編譯完成