Boost入门(linux)
Index
1 获取boost
获取 Boost 副本的最可靠方法是从SourceForge下载发行版:
-
在你想安装Boost 的目录中,执行
tar --bzip2 -xf /path/to/boost_1_76_0.tar.bz2
2 Boost 目录结构
这是生成的目录结构的草图:
boost_1_76_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 docs
头文件组织
Boost 库头文件的组织并不完全统一,但大多数库都遵循一些模式:
-
一些较旧的库和大多数非常小的库将所有公共头文件直接放入boost /。
-
大多数库的公共头文件都位于boost /的子目录中 ,以库的名字命名。例如,您将在以下位置找到 Python 库的def.hpp标头
boost/python/def.hpp.
-
一些库在boost /中有一个“聚合头文件” , #include包含该库的所有其他头文件。例如,Boost.Python的聚合头文件是
boost/python.hpp.
-
大多数库将私有头文件放在名为detail /或aux_ /的子目录中 。不要指望在这些目录中找到任何可以使用的东西。
请务必注意以下几点:
-
boost 根目录(通常为/usr/local/ boost_1_76_0)的路径有时在文档和邮件列表中称为$BOOST_ROOT。
-
为了编译依赖boost的项目,需要需要在引用目录中加上这样一个目录:boost/子目录所在的目录。
-
由于所有 Boost 的头文件都具有.hpp扩展名,并且位于boost 根目录的boost /子目录中,因此您的 Boost #include指令将如下所示:
#include <boost/whatever.hpp>
或者
#include "boost/whatever.hpp"
这取决于您的偏好。
-
不要被doc /子目