boost库安装记录

2022-05-23  本文已影响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、一些库有可选的单独编译的二进制文件:

四、示例

#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
上一篇下一篇

猜你喜欢

热点阅读