当前位置:网站首页>Boost library study notes (1) Installation and configuration
Boost library study notes (1) Installation and configuration
2022-08-04 17:02:00 【Moresweet cat sweet】
Boost库学习笔记(一)安装与配置
1. 获取boost
https://www.boost.org/users/history/version_1_79_0.html
任选其一
boost的目录结构:
tip:
- boostLibrary the root directory of the library should set the environment variable**$BOOST_ROOT** 中,笔者路径为(D:\Software\boost_1_79_0)
- 编译boost程序时,你需要将boostThe header file directory added,笔者路径为(D:\Software\boost_1_79_0\boost)
Only the header file library:
大多数的boost库都是header-only的,The header file already contains templates and inline function,Don't need separate compilation or special treatment when link.
Of course there are some libraries need to separate compilation to use:
There are a few is optional separate compilation:
- 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
random_device
. - 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
2.Windows安装过程
使用windowsThe command prompt with administrator permissions to open,切换到boost的根目录.
bootstrap.bat # 执行bootstrap.bat的批处理
# 运行完成后会生成b2.exe程序
b2.exe # 开始编译工作
b2.exeProgram can support parameters are:
toolset
编译器类别,可以是gcc,或者是msvctarget-os
目标操作系统,可以是Windows,Linuxvariant
生成类型,可以是 debug(-gd-)或者release (-)threadapi
线程API的实现,可以是win32或者pthread,在windows上编译就用win32link
链接库类型,可以是静态的static,也可以是shared,对应windows上的库就是.lib或者是dllruntime-link
动态还是静态链接C/C++运行时库.同样有shared (-)和static (-s-)两种方式,这样runtime-link和link可以产生4种组合方式,可以根据需要选择编译.prefix
安装路径user-config
用户自定义配置文件,在cross compile的时候可以用来配置编译工具链address-model
生成32位还是64位库文件architecture=x86
cpu架构,一般台式机位x86,嵌入式平台位arm
编译安装64位的Release版的静态链接库可以执行下面的指令:(-mt-s-)
.\b2.exe variant=release threading=multi threadapi=win32 link=static runtime-link=static --prefix=E:\boost_1_77_0 address-model=64 architecture=x86 install -j8
From this paragraphhttps://www.cnblogs.com/lylygoing/p/BoostDownload.html
当没有指定参数的时候,The default compiler generated in the current directory.
从输出可以看出,头文件在D:\Software\boost_1_79_0
,The path of the link libraries inD:\Software\boost_1_79_9\stage\lib
下,Which also would generatebin.v2的目录,大小在2.3G左右,可以直接删除.
3. Linux安装过程
下载
https://www.boost.org/users/history/version_1_79_0.htmltar -xzvf boost_1_79_0.tar.gz #解压 cd boost_1_79_0 #进入目录 vim bootstrap.sh #修改prefix为指定目录,笔者为/usr/local/boost1.79 ./bootstrap.sh sudo ./b2 install # 不加sudoStill generated in this directory
4.VSThe compilation of prepared
创建新项目(VS2022)
新建一个源文件
粘贴以下代码
#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) << " "); }
The solution configuration
5.测试运行
Every time the output you input values three times
6.要点总结
- To install, perform beforebootstrap的脚本文件(Windows执行.bat,Linux执行.sh),之后再执行b2Program compiles the installation,Pay attention to the parameters can be specified.
- 使用BoostIf master additional the header files and libraries directory,What kind of tools are to follow the principle of the.
边栏推荐
猜你喜欢
广东移动魔百盒M411A _905L3_线刷固件包
咪咕MGV2000KL南传_S905L3B_MT7668线刷固件包
88.(cesium之家)cesium聚合图
Mobile magic box CM211-1_YS foundry _S905L3B_RTL8822C_wire brush firmware package
葫芦娃解析
移动海信IP102H_905L3-B_线刷固件包
如何提高员工积极性?
御神楽的学习记录之基于FPGA的AHT10温湿度数据采集
谷歌开发者社区推荐:《Jetpack Compose 从入门到实战》新书上架,带你踏上 Compose 开发之旅~
leetcode 48. Rotate Image 旋转图像(Medium)
随机推荐
Win10 无线网卡驱动感叹号,显示错误代码56
AtCoder Beginner Contest 262 部分题解
Mobile magic box CM211-1_YS foundry _S905L3B_RTL8822C_wire brush firmware package
数据库内核面试中我不会的问题(2)
机器人示教编程与离线编程的优缺点对比
北京海淀6家必胜客被暂停外卖订餐 存在食品安全问题
LeetCode 0168. Excel表列名称
18 Data Collection Analysis
机器学习(十九):梯度提升回归(GBR)
WPF 光标初始化的时候 temp 文件夹满了无法创建
罗振宇折戟创业板/ B站回应HR称用户是Loser/ 腾讯罗技年内合推云游戏掌机...今日更多新鲜事在此...
越来越火的图数据库到底能做什么?
抖音最重要的接口——item_search_video-根据关键词获取视频列表
机器学习(十八):随机搜索和XGBoost
浙江移动咪咕MGV2000-K4_ZJ_S905l2_7661_线刷固件包
拼多多详情API接口深度解读
生产环境重大bug,update加上索引字段会走索引进行更新?还是走全表扫描
Hubei Mobile ZTE B860AV2.1_S905L_ flash firmware package
海报 | 夏季高温,危化品安全风险的注意事项必须get!
太一集团宣布全资收购火币旗下社交产品火信