美文网首页
boost库安装记录

boost库安装记录

作者: 秋冬不寒 | 来源:发表于2022-05-23 22:45 被阅读0次

    一、下载boost

    1. Download .

    2. 在boost库安装目录中解压
      tar --bzip2 -xf /path/to/boost_1_79_0.tar.bz2

    二、boost发行版

    目录结构

    * 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. 因为所有的boost头文件都有.hpp扩展名,并且位于boost根目录的boost /子目录中,所以boost #include指令可以:
      #include <boost/whatever.hpp>
      #include "boost/whatever.hpp"
    3. 不要被doc/子目录分心;它只包含boost文档的一个子集。如果您想要查找全部内容,请从libs/index.html开始。

    三、构建boost

    1、大部分boost不需要构建,是head-only的库。
    2、需要编译的库有:

    3、一些库有可选的单独编译的二进制文件:

    • 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. 结果如下:


      运行结果.png

    相关文章

      网友评论

          本文标题:boost库安装记录

          本文链接:https://www.haomeiwen.com/subject/gmsdprtx.html