当前位置:网站首页>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=x86cpu架构,一般台式机位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.html![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-JdOpAUfy-1659447175784)(imgs/image-20220802152104328.png)]](/img/59/75de0568d4bdfc77c5fd65e033451b.png)
tar -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
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-7t1lWTu5-1659447175796)(imgs/image-20220802212612696.png)]](/img/33/10deb9d4bd172877f07473d740a2df.png)
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.
边栏推荐
- 海报 | 夏季高温,危化品安全风险的注意事项必须get!
- 从正负样本解耦看对比学习为何需要large batch size训练Ddcoupled Contrastive learning (DCT)
- 西西成语接龙小助手
- Mobile BesTV_R3300-L_S905L_8189_wire brush firmware package
- LeetCode 0167. 两数之和 II - 输入有序数组
- 九联_UNT400G_S905L2_(联通)_线刷固件包
- 小程序+自定义插件的混合模式
- 机器学习(十九):梯度提升回归(GBR)
- 麒麟信安石勇博士荣获openEuler社区年度开源贡献之星
- SRM供应商协同管理系统功能介绍
猜你喜欢
随机推荐
Cesium快速上手0-Cesium安装与基本介绍
HCIP笔记(8)
数字化金融企业的产品体系长啥样?
Go语言gin框架返回json格式里,怎么把某个int属性转成string返回?
《分布式云最佳实践》分论坛,8月11日深圳见
全世界国家和地区国家顶级域名对照表
Hubei Mobile ZTE B860AV2.1_S905L_ flash firmware package
九联_UNT400G_S905L2_(联通)_线刷固件包
Selenium Webdriver驱动自管理
手把手教你搭建一个Minecraft 服务器
咪咕MGV2000KL南传_S905L3B_MT7668线刷固件包
WEB 渗透之逻辑漏洞
JVM内存和垃圾回收-08.方法区
ping不通百度
水能自发变成“消毒水”,83岁斯坦福教授:揭示冬天容易得流感的部分原因...
Win10 无线网卡驱动感叹号,显示错误代码56
机器人示教编程与离线编程的优缺点对比
泰坦尼克号沉船数据之美——起于悲剧,止于浪漫
拼多多详情API接口深度解读
移动中兴ZXV10 B860AV2.1-A_S905L2_MT7668_线刷固件包









