AndreaDO

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

windows-vs2022-配置boost开发

windows-vs2022-配置boost开发

1.先去官网下载boost库最新版本

https://www.boost.org/users/download/
选择windows版本下载,zip和7z格式的都可以
image

2.下载解压后点击bootstrap.bat文件,双击运行会生成b2.exe

image

然后输入下述命令进行编译,编译时间会比较长,分别针对的是32位和64位,prefix是你想要编译后放在什么地方

b2.exe install --prefix="E:/Boost/x64" --build-type=complete --toolset=msvc-14.3 threading=multi --build-type=complete address-model=64

b2.exe install --prefix="E:/Boost/x86" --build-type=complete --toolset=msvc-14.3 threading=multi --build-type=complete address-model=32

编译时间有点长,慢慢等一会就好

3.去vs2022里右键项目的属性

如图平台工具集后(v143)就是14.3
image

在VC++目录中修改这两处:包含目录库目录

包含目录是你boost解压后的主目录
image

库目录是你编译后的目录
image
这两处修改完成后就基本上没事了

4.编写代码测试

#include <iostream>
#include <string>
#include "boost/lexical_cast.hpp"
int main()
{
    using namespace std;
    cout << "Enter your weight: ";
    float weight;
    cin >> weight;
    string gain = "A 10% increase raises ";
    string wt = boost::lexical_cast<string> (weight);
    gain = gain + wt + " to ";      // string operator()
    weight = 1.1 * weight;
    gain = gain + boost::lexical_cast<string>(weight) + ".";
    cout << gain << endl;
    system("pause");
    return 0;
}

可以正常输出运行,我们这里就配置结束了
image

posted on   AndreaDO  阅读(1118)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 上周热点回顾(2.17-2.23)
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 如何使用 Uni-app 实现视频聊天(源码,支持安卓、iOS)
点击右上角即可分享
微信分享提示