当前位置:网站首页>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.
边栏推荐
猜你喜欢
随机推荐
SAP 电商云 Spartacus UI SSR 单元测试里的 callFake
dotnet remoting 抛出异常
shell脚本详解 --------循环语句之for循环
西西成语接龙小助手
黑龙江移动新魔百盒M411A_2+8_S905L3A_线刷固件包
WEB 渗透之逻辑漏洞
数字化金融企业的产品体系长啥样?
乐享购(分享购)的模式:优势、亮点、收益
LeetCode 0167. 两数之和 II - 输入有序数组
jMeter Transaction Controller 学习笔记
pygame的freetype模块
Compose 类型稳定性注解:@Stable & @Immutable
HCIP笔记(8)
15 days to upgrade to fight monsters and become a virtual fashion creator
Taurus.MVC WebAPI 入门开发教程2:添加控制器输出Hello World。
ping不通百度
AtCoder Beginner Contest 262 部分题解
gcc7.5.0编译ceres-solver报错‘is_trivially_default_constructible’ is not a member of ‘std’
域名哪家便宜?怎么买便宜域名?
跨域传递数据(iframe)