Boost是为C++语言标准库提供扩展的一些C++程序库的总称。Boost库是一个可移植、提供源代码的C++库,作为标准库的后备,是C++标准化进程的开发引擎之一,是为C++语言标准库提供扩展的一些C++程序库的总称。
Boost库由C++标准委员会库工作组成员发起,其中有些内容有望成为下一代C++标准库内容。在C++社区中影响甚大,是不折不扣的“准”标准库。
- HP-EliteDesk-880-G2-TWR:~/boost_1_80_0$ tree -L 1
- .
- ├── boost #所有boost库头文件,90%以上的boost库源码都在这里
- ├── boost-build.jam
- ├── boostcpp.jam
- ├── boost.css
- ├── boost.png
- ├── bootstrap.bat
- ├── bootstrap.sh
- ├── doc #文档
- ├── index.htm
- ├── index.html
- ├── INSTALL
- ├── Jamroot
- ├── libs #所有组件的示例/测试/编译代码和说明文档
- ├── LICENSE_1_0.txt
- ├── more #库作者相关的文档
- ├── README.md
- ├── rst.css
- ├── status #可用于测试boost库的各个组件
- └── tools #b2、quickbook等一些自带的工具
-
- 6 directories, 13 files
boost子目录是最为重要的目录。以头文件的形式分门别类存放了要使用的库代码:
- ├─accumulators #累加器库
- ├─algorithm #算法库
- ├─archive #序列化库
- ├─asio #异步并发库
- ├─assign #赋值初始化库
- ├─atomic #原子操作库
- ├─bimap #双向关联数组
- ├─bind #bind表达式
- ├─chrono #时间处理库
- ├─circular_buffer #循环缓冲区容器
- ... #其他库
- ...
- └─xpressive #正则表达式库
- HP-EliteDesk-880-G2-TWR:~/boost_1_80_0$ ./bootstrap.sh -h
- `./bootstrap.sh\' builds the Boost build system B2 and prepares Boost for
- building. This includes setting defaults in the project-config.jam which you
- can adjust prior to invoking B2.
-
- Usage: ./bootstrap.sh [OPTION]...
-
- Defaults for the options are specified in brackets.
-
- Configuration:
- -h, --help display this help and exit
- --with-bjam=BJAM use existing Boost.Jam executable (bjam)
- [automatically built]
- --with-toolset=TOOLSET use specific TOOLSET to build B2 and as default
- for building Boost
- [automatically detected]
- --show-libraries show the set of libraries that require build
- and installation steps (i.e., those libraries
- that can be used with --with-libraries or
- --without-libraries), then exit
- --with-libraries=list build only a particular set of libraries,
- describing using either a comma-separated list of
- library names or "all"
- [all]
- --without-libraries=list build all libraries except the ones listed []
- --with-icu enable Unicode/ICU support in Regex
- [automatically detected]
- --without-icu disable Unicode/ICU support in Regex
- --with-icu=DIR specify the root of the ICU library installation
- and enable Unicode/ICU support in Regex
- [automatically detected]
- --with-python=PYTHON specify the Python executable [python]
- --with-python-root=DIR specify the root of the Python installation
- [automatically detected]
- --with-python-version=X.Y specify the Python version as X.Y
- [automatically detected]
-
- Installation directories:
- --prefix=PREFIX install Boost into the given PREFIX
- [/usr/local]
- --exec-prefix=EPREFIX install Boost binaries into the given EPREFIX
- [PREFIX]
-
- More precise control over installation directories:
- --libdir=DIR install libraries here [EPREFIX/lib]
- --includedir=DIR install headers here [PREFIX/include]
某些库不需要编译,包含头文件就可以使用,有些需要编译后才能使用。
以下是必须编译成静态库或动态库才能使用的boost库:
- HP-EliteDesk-880-G2-TWR:~/boost_1_80_0$ ./bootstrap.sh --show-libraries
- Building B2 engine..
-
- ###
- ###
- ### Using 'gcc' toolset.
- ###
- ###
-
- g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
- Copyright (C) 2019 Free Software Foundation, Inc.
- This is free software; see the source for copying conditions. There is NO
- warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-
- ###
- ###
-
- > g++ -x c++ -std=c++11 -O2 -s -DNDEBUG builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp execunix.cpp filesys.cpp filent.cpp fileunix.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam_strings.cpp jam.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp pathunix.cpp regexp.cpp rules.cpp scan.cpp search.cpp startup.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp -o b2
- tools/build/src/engine/b2
-
- The following Boost libraries have portions that require a separate build
- and installation step. Any library not listed here can be used by including
- the headers only.
-
- The Boost libraries requiring separate building and installation are:
- - atomic
- - chrono
- - container
- - context
- - contract
- - coroutine
- - date_time
- - exception
- - fiber
- - filesystem
- - graph
- - graph_parallel
- - headers
- - iostreams
- - json
- - locale
- - log
- - math
- - mpi
- - nowide
- - program_options
- - python
- - random
- - regex
- - serialization
- - stacktrace
- - system
- - test
- - thread
- - timer
- - type_erasure
- - wave
先使用不需要编译的库,直接使用头文件,测试代码:
- #include
//不需要单独编译的库 - #include
-
- using namespace std;
-
- int main()
- {
- using boost::lexical_cast;
-
- int a=lexical_cast<int>("123");
- double b=lexical_cast<double>("123.0123456789");
- string s0=lexical_cast
(a); - string s1=lexical_cast
(b); - cout<<"number: "<" "<
- cout<<"string: "<
" "< - int c=0;
- try{
- c=lexical_cast<int>("abcd");
- }
- catch(boost::bad_lexical_cast& e){
- cout<
what()< - }
-
- return 0;
- }
四、裁剪
假设我们允许程序员用A、B、C、D这样四个模块,那么可以这样:
bcp --boost: A B C D
这里A、B、C、D可以是:
Boost的头文件名。如: boost/shared_ptr.hpp
Boost的库名。如:regex
Boost的头文件标题:boost/shared_ptr 或者 shared_ptr
如果是在boost根目录下,那指定boost目录的参数也可以省去。
使用 bcp 裁剪 boost 库_丛继晔的博客-CSDN博客_boost 裁剪
ref:
嵌入式linux开发,boost移植,boost交叉编译_寞水的博客-CSDN博客_boost移植
boost库不安装使用和安装使用_fengyun_w的博客-CSDN博客
windows下编译和安装boost库 - rangers - 博客园
-
相关阅读:
CYEZ 模拟赛 5
js原型链污染详解
常见内置函数
视频用二维码怎么分享?扫码看视频在线制作方法
4.Nginx优化,谁用谁说好
【人民币识别】人民币序列号识别【含GUI Matlab源码 908期】
【下一代对象专题】小文件管理全线升级,性能提升60%
C++面试八股文:了解sizeof操作符吗?
mysql基础_索引
RK3568技术笔记 Ubuntu 安装VMware Tools
-
原文地址:https://blog.csdn.net/wwwlyj123321/article/details/126637595
-
最新文章
-
沪漂五周年了:我越来越迷茫了
Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
MySQL-Seconds_behind_master的精度误差
[MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
Agent OS :五种驯服不确定性的范式
PortSwigger SQL注入LAB11
数据库即时编译JIT
[Begin]AI Learn Data Day 0
深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU