VS2019配置BOOST的方法(v1.70.0库)

发布时间:2020-10-22 16:37:10 作者:RiskAI
来源:脚本之家 阅读:360

安装编译Boost c++ library

安装Boost库

官网下载:https://www.boost.org/users/history/version_1_70_0.html

最新版本1.70.0. (低于1.7.0的版本可能在vs2019中支持不完善,编译或运行时发生不可预料的bug)

下载好后,解压,得到文件目录如下图,找到其中的bootstrap.bat文件:

VS2019配置BOOST的方法(v1.70.0库)

双击运行可能出现闪退,最好的办法(亲测有效): 选择vs2019 —> visual studio tools —> vc —> x86_x64 Cross Tools Command Prompt for VS 2,打开命令行:

VS2019配置BOOST的方法(v1.70.0库)

VS2019配置BOOST的方法(v1.70.0库)

切换到boost_1_70_0的安装目录,(本人安装路径:E:\program\boost_1_70_0)

cd E:\program\boost_1_70_0
bootstrap.bat # 执行

执行会发现当前文件夹中增加了几个文件,找到其中的bjam.exe,如下图所示

VS2019配置BOOST的方法(v1.70.0库)

命令行执行:

bjam.exe --toolset=msvc-14.1 architecture=x86 address-model=64 link=static --build-type=complete --with-system --with-thread --with-date_time --with-filesystem --with-serialization

Note:

MSVC 版本号对应

1.MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
2.MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
3.MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
4.MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
5.MSVC++ 9.0  _MSC_VER == 1500 (Visual Studio 2008)
6.MSVC++ 8.0  _MSC_VER == 1400 (Visual Studio 2005)
7.MSVC++ 7.1  _MSC_VER == 1310 (Visual Studio 2003)
8.MSVC++ 7.0  _MSC_VER == 1300
9.MSVC++ 6.0  _MSC_VER == 1200
10.MSVC++ 5.0  _MSC_VER == 1100

vs2019 可以支持boost c++ library 针对msvc-14.1的编译选项

等待5-10min即可完成。

最后两个路径会在使用Boost库时工程属性中包含目录和库目录中用到。

The Boost C++ Libraries were successfully built.
the following directory should be added to compiler include paths:
E:\program\boost_1_70_0
the following directory should be added to linker library paths:
E:\program\boost_1_70_0\stage\lib

这时boost库已经安装、编译成功。

新建vs2019 c++项目,并添加boost依赖库

点击菜单栏 项目——>属性——>选择VC++目录,在包含目录 和 库目录添加以上2个路径,如下图:

VS2019配置BOOST的方法(v1.70.0库)

或可以新建一个系统环境变量BOOST_DIR,值为E:\program\boost_1_70_0。

在path系统环境变量中添加:%BOOST_DIR%;

VC++包含目录中添加: %BOOST_DIR%;

VC++库目录中添加: %BOOST_DIR%\stage\lib;

代码测试

#include <boost/lexical_cast.hpp>   
#include <iostream>  

using namespace std;
using namespace boost;

int main()
{
	//system("chcp 65001");

	double a = lexical_cast<double>("3.1415926");
	string str = lexical_cast<string>("3.1415926");
	cout << "This is a number: " << a << endl;
	cout << "This is a string: " << str << endl;
	int b = 0;
	try {
		b = lexical_cast<int>("neo");
	}
	catch (bad_lexical_cast& e) {
		cout << e.what() << endl;
	}
	return 0;
}

运行输出(正常):

This is a number: 3.14159
This is a string: 3.1415926
bad lexical cast: source type value could not be interpreted as target

c++ boost库说明

c++ boost库官网

官网最新版文档说明:https://www.boost.org/doc/libs/1_70_0/

refer: 百度百科

Boost库是一个可移植、提供源代码的C++库,作为标准库的后备,是C++标准化进程的开发引擎之一,是为C++语言标准库提供扩展的一些C++程序库的总称。 Boost库由C++标准委员会库工作组成员发起,其中有些内容有望成为下一代C++标准库内容。在C++社区中影响甚大,是不折不扣的“准”标准库。Boost由于其对跨平台的强调,对标准C++的强调,与编写平台无关。大部分boost库功能的使用只需包括相应头文件即可,少数(如正则表达式库,文件系统库等)需要链接库。但Boost中也有很多是实验性质的东西,在实际的开发中使用需要谨慎。

Boost库由Boost社区组织开发、维护。其目的是为C++程序员提供免费、同行审查的、可移植的程序库。Boost库可以与C++标准库完美共同工作,并且为其提供扩展功能。Boost库使用Boost License来授权使用。

Boost社区建立的初衷之一就是为C++的标准化工作提供可供参考的实现,Boost社区的发起人Dawes本人就是C++标准委员会的成员之一。在Boost库的开发中,Boost社区也在这个方向上取得了丰硕的成果。在送审的C++标准库TR1中,有十个Boost库成为标准库的候选方案。在更新的TR2中,有更多的Boost库被加入到其中。从某种意义上来讲,Boost库成为具有实践意义的准标准库。
可下载Boost C++ Libraries安装boost库。大部分boost库功能的使用只需包括相应头文件即可,少数(如正则表达式库,文件系统库等)需要链接库。里面有许多具有工业强度的库,如graph库。

主要分类

按照功能分类的Boost库列表
按照实现的功能,Boost 可为大致归入以下20个分类,在下面的分类中,有些库同时归入几种类别。
字符串和文本处理
a) Conversion
b) Format
c) IOStream
d) Lexical Cast
e) Regex
f) Spirit
g) String Algo
h) Tokenizer
i) Wave
j) Xpressive

容器
a) Array
b) Bimap
c) Circular Buffer
d) Disjoint Sets
e) Dynamic Bitset
f) GIL
g) Graph
h) ICL
i) Intrusive
j) Multi-Array
k) Multi-Index
l) Pointer Container
m) Property Map
n) Property Tree
o) Unordered
p) Variant

迭代器
a) GIL
b) Graph
c) Iterators
d) Operators
e) Tokenizer

算法
a) Foreach
b) GIL
c) Graph
d) Min-Max
e) Range
f) String Algo
g) Utility

函数对象和高阶编程
a) Bind
b) Function
c) Functional
d) Functional/Factory
e) Functional/Forward
f) Functional/Hash
g) Lambda
h) Member Function
i) Ref
j) Result Of
k) Signals
l) Signals2
m) Utility

泛型编程
a) Call Traits
b) Concept Check
c) Enable If
d) Function Types
e) GIL
f) In Place Factory, Typed In Place Factory
g) Operators
h) Property Map
i) Static Assert
j) Type Traits

模板元编程

a) Function Types
b) Fusion
c) MPL
d) Proto
e) Static Assert
f) Type Traits

预处理元编程
a) Preprocessors

并发编程

a) Asio
b) Interprocess
c) MPI
d) Thread

数学和数字

a) Accumulators
b) Integer
c) Interval
d) Math
e) Math Common Factor
f) Math Octonion
g) Math Quaternion
h) Math/Special Functions
i) Math/Statistical Distributions
j) Multi-Array
k) Numeric Conversion
l) Operators
m) Random
n) Rational
o) uBLAS

排错和测试

a) Concept Check
b) Static Assert
c) Test

数据结构

a) Any
b) Bitmap
c) Compressed Pair
d) Fusion
e) ICL
f) Multi-Index
g) Pointer Container
h) Property Tree
i) Tuple
j) Uuid
k) Variant

图像处理

a) GIL

输入输出

a) Asio
b) Assign
c) Format
d) IO State Savers
e) IOStreams
f) Program Options
g) Serialization

跨语言混合编程

a) Python

内存管理

a) Pool
b) Smart Ptr
c) Utility

解析
a) Spirit

编程接口
a) Function
b) Parameter

杂项
a) Compressed Pair
b) Conversion
c) CRC
d) Date Time
e) Exception
f) Filesystem
g) Flyweight
h) Lexical Cast
i) Meta State Machine
j) Numeric Conversion
k) Optional
l) Polygon
m) Program Options
n) Scope Exit
o) Statechart
p) Swap
q) System
r) Timer
s) Tribool
t) Typeof
u) Units
v) Utility
w) Value Initialized

编译器问题的变通方案

a) Compatibility
b) Config

常用库

相关图书编辑

到此这篇关于VS2019配置BOOST的方法(v1.70.0库)的文章就介绍到这了,更多相关VS2019配置BOOST内容请搜索亿速云以前的文章或继续浏览下面的相关文章希望大家以后多多支持亿速云!

推荐阅读:
  1. mysql-boost-5.7.18安装方法
  2. NDK 编译 boost库

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

vs2019 配置 boost

上一篇:云服务器可以初始化吗

下一篇:ftp上传云服务器异常怎么解决

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》