boost庫安裝記錄

一、下載boost

  1. Download .

  2. 在boost庫安裝目錄中解壓
    tar --bzip2 -xf /path/to/boost_1_79_0.tar.bz2

二、boost發(fā)行版

目錄結(jié)構(gòu)

* boost_1_79_0/ .................The “boost root directory”
  * index.htm .........A copy of www.boost.org starts here
  * boost/ .........................All Boost Header files
  *  libs/ ............Tests, .cpps, docs, etc., by library
      *  index.html ........Library documentation starts here
      *   algorithm/
      * any/
      *  array/
         …more libraries…
  *  status/ .........................Boost-wide test suite
  *   tools/ ...........Utilities, e.g. Boost.Build, quickbook, bcp
  *   more/ ..........................Policy documents, etc.
  *   doc/ ...............A subset of all Boost library doc
  1. ** $BOOST_ROOT**通常是boost root directory (often /usr/local/boost_1_79_0)
  2. 因?yàn)樗械腷oost頭文件都有.hpp擴(kuò)展名,并且位于boost根目錄的boost /子目錄中,所以boost #include指令可以:
    #include <boost/whatever.hpp>
    #include "boost/whatever.hpp"
  3. 不要被doc/子目錄分心;它只包含boost文檔的一個(gè)子集。如果您想要查找全部內(nèi)容,請(qǐng)從libs/index.html開始。

三、構(gòu)建boost

1、大部分boost不需要構(gòu)建,是head-only的庫。
2、需要編譯的庫有:

3、一些庫有可選的單獨(dú)編譯的二進(jìn)制文件:

  • 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 <tt class="docutils literal">random_device</tt>.
  • 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.
  • Boost.System is header-only since Boost 1.69. A stub library is still built for compatibility, but linking to it is no longer necessary.

四、示例

#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>

int main()
{
    using namespace boost::lambda;
    typedef std::istream_iterator<int> in;

    std::for_each(
        in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
  1. c++ -I path/to/boost_1_79_0 example.cpp -o example
  2. echo 1 2 3 | ./example
  3. 結(jié)果如下:


    運(yùn)行結(jié)果.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容