轉載請注明出處:
http://www.cnblogs.com/darkknightzh/p/5797940.html
參考網址:
http://www.boost.org/doc/libs/1_61_0/more/getting_started/unix-variants.html
http://blog.csdn.net/tedious/article/details/6793544
說明:boost庫包含兩部分:無需編譯的頭文件,及單獨編譯的庫。單獨編譯的庫如下:
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.
安裝步驟(首先下載並解壓縮文件,並cd到該文件夾內):
1. 運行bootstrap.sh:后面加上需要編譯的庫(如果不加的話,貌似只會編譯最小的庫,即包含基本功能的庫)需要編譯的自己選(可以見參考網址2里面完全編譯)。
./bootstrap.sh --with-libraries= system,filesystem, thread,python
經過上命令后,可以看到,會編譯哪些庫:

2. 運行./b2。直接這樣用,提示權限不夠,所以使用如下命令就可以成功:
sudo ./b2
成功編譯了這些文件(和上圖對應的庫):

3. 將編譯好的文件使用cp命令拷貝到系統的目錄:
sudo cp -a stage/lib /usr/local sudo cp -a boost /usr/local/include/boost
ps. 貌似這些目錄不是ubuntu默認的庫目錄。ubuntu默認庫目錄是/usr/lib。所以上面拷貝時,可以使用:
sudo cp -a stage/lib /usr sudo cp -a boost /usr/include
說明:
1. 使用--show-libraries查看哪些需要單獨編譯:
./bootstrap.sh --show-libraries

2. 全編譯(沒試過):
./bootstrap.sh --with-libraries= atomic,chrono,container,context,coroutine,coroutine2,date_time,exception,filesystem,graph,graph_parallel,iostreams,locale,with-log,math,metaparse,mpi,program_options,python,random,regex,serialization,signals,system,test,thread,timer,type_erasure,wave
在另一台電腦上,使用./bootstrap.sh --with-libraries= system,filesystem, thread,python,結果全編譯出來了。。。
