Visual Studio2019编译Boost源码1.7.4


最近想把ORB_SLAM3在windows上编译运行,因为最新的的ORB_Slam3需要用到Boost这个库,因此将Boost库的编译过程记录下来。

一、下载

到官网下载:下载地址
在这里插入图片描述

二、解压

三、利用VS cmd进行编译

打开vs2019的 x86_x64 Cross Tools Command Prompt for VS工具
在这里插入图片描述
然后运行以下命令(我的boost解压路径为E:\App_Lib\boost_1_74_0,根据自己的路径进行修改)

cd \
E:
cd E:\App_Lib\boost_1_74_0
bootstrap.bat

然后执行命令

.\b2.exe

四、VS新建项目测试编译好的Boost库

在项目属性->所有选项->附加包目录->选择以下目录添加(依赖项和头文件)

E:\App_Lib\boost_1_74_0
E:\App_Lib\boost_1_74_0\stage\lib

在这里插入图片描述

五、测试代码

测试代码1

#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;
}

测试代码2

#include <iostream>
#include <boost/sort/sort.hpp>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
	vector<int> arr;
	while (arr.size() < 100) arr.push_back(std::rand());
	boost::sort::block_indirect_sort(std::begin(arr), std::end(arr));
	for_each(std::begin(arr), std::end(arr), [](int& a) {
		cout << a << "\t";
		});
	return 0;
}
  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值