当前位置:网站首页>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.
边栏推荐
猜你喜欢
随机推荐
移动CM101s_MV100_EMMC_M8233_强刷后全分区线刷固件包
地理标志农产品需双重保护
SAP 电商云 Spartacus UI SSR 单元测试里的 callFake
88.(cesium之家)cesium聚合图
太一集团宣布全资收购火币旗下社交产品火信
Go语言gin框架返回json格式里,怎么把某个int属性转成string返回?
广东移动魔百盒M411A _905L3_线刷固件包
餐饮供应链管理系统
GraphQL 入门与实践
Minecraft HMCL 第三方启动器使用教程
18数藏解析
并发编程原理学习-reentrantlock源码分析
R语言使用yardstick包的gain_curve函数评估多分类(Multiclass)模型的性能、查看模型在多分类每个分类上的增益(gain)曲线(gain curve)
域名哪家便宜?怎么买便宜域名?
一张图片怎么旋转90度。利用ps
icu是哪个国家的域名?icu是什么域名?
理财产品买入后份额是固定不变的吗?
Minecraft 我的世界 .minecraft下的各个文件夹的用处
御神楽的学习记录之基于FPGA的AHT10温湿度数据采集
机器学习(十三):支持向量机(SVM)








