网站建设盐城,有没有免费网站制作,做网站广告联盟赚钱,济南网站建设行知keji文章目录 Boost exe版本windows环境安装vscode配置安装测试总结 Boost exe版本windows环境安装
这里不介绍boost源码安装#xff0c;请自行网络搜索。本文要介绍的是window下单c文件#xff08;cpp#xff09;#xff0c;调用boost库的执行配置。不涉及多文件。 安装文件下… 文章目录 Boost exe版本windows环境安装vscode配置安装测试总结 Boost exe版本windows环境安装
这里不介绍boost源码安装请自行网络搜索。本文要介绍的是window下单c文件cpp调用boost库的执行配置。不涉及多文件。 安装文件下载地址
下载版本boost_1_87_0-msvc-14.1-32.exe 。最新版本请访问这里下载 本人安装路径D:\software\boost_1_87_0
配置环境变量 配置boost头文件和库文件环境变量 BOOST_INCLUDEDIR 和 BOOST_LIBRARYDIR path 中添加 D:\soft\boost\172\lib64-msvc-14.2
vscode配置
vscode安装和C开发环境配置这里不表述请网络自行搜索。运行C文件需要。vscode请安装code runner插件。 测试目录创建.vscode目录目录中创建相关json配置文件。直接上相关配置文件。
task.json
{version: 2.0.0,tasks: [{type: cppbuild,label: C/C: g.exe build active file,command: D:\\software\\mingw64-14.2\\bin\\g.exe,args: [-I,D:\\software\\boost_1_87_0,-fdiagnostics-coloralways,-g,${file},-g, // 生成调试相关信息-Wall, // 生成额外告警信息-static-libgcc, // 静态libgcc一般都会加上 -o,${fileDirname}\\${fileBasenameNoExtension}.exe,-stdc17],options: {cwd: D:/software/mingw64-14.2/bin},// problemMatcher: [$gcc], // 此选项可以捕捉编译时终端里的报错信息但因为有Lint再开...group: {kind: build,isDefault: true // 不为true时 ctrl shift B时就需要手工选择},detail: D:\\software\\mingw-64\\mingw64-8.1\\bin\\g.exe,presentation: {echo: true,reveal: always, // 执行任务时是否跳转到终端面板可以为always,silent,neverfocus: false, // 设为true后可以使执行task时焦点聚集在终端但对编译C/C来讲...panel: shared // 不同的文件的编译信息共享一个终端面板},}]
}lanch.json
{version: 0.2.0,configurations: [{name: 调试C程序,type: cppdbg,request: launch,program: ${fileDirname}/${fileBasenameNoExtension}.exe, // 指定要调试的程序路径args: [],stopAtEntry: false,cwd: ${workspaceFolder},environment: [],externalConsole: false,MIMode: gdb, // 使用gdb作为调试器。miDebuggerPath: gdb, // gdb的路径。如果未添加到PATH环境变量需要填写完整路径。setupCommands: [{description: 启用调试打印,text: -enable-pretty-printing,ignoreFailures: true}]}]
}c_cpp_properties.json
{configurations: [{name: Win32,includePath: [${workspaceFolder}/**,D:\\software\\boost_1_87_0],defines: [_DEBUG,UNICODE,_UNICODE],compilerPath: D:\\software\\mingw64-14.2\\bin\\g.exe,cStandard: c17, // 指定C的标准版本cppStandard: c17, // 指定C的标准版本intelliSenseMode: windows-gcc-x64 // 指定IntelliSense的模式}],version: 4
}settings.json
{cmake.configureOnOpen: true,files.associations: {*.ipp: cpp,valarray: cpp},code-runner.executorMap:{cpp: cd $dir g $fileName -I \D:\\software\\boost_1_87_0\ -o $fileNameWithoutExt $dir$fileNameWithoutExt,}
}说明如果没有code-runner.executorMap配置vscode code runner执行cpp时会提示如下类似找不到boost头文件的错误
[Running] cd e:\codes\C\myC\test\ g main.cpp -o main e:\codes\C\myC\test\main
main.cpp:1:10: fatal error: boost/algorithm/string.hpp: No such file or directory1 | #include boost/algorithm/string.hpp| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.[Done] exited with code1 in 7.869 seconds安装测试
测试代码
#include boost/algorithm/string.hpp
#include iostreamusing namespace std;
using namespace boost;int main()
{cout ------------测试boost库安装是否正确------------ endl;std::string s ismileli;// 把字符串小写转换为大写std::cout boost::algorithm::to_upper_copy(s) std::endl;std::cout Hello World!\n;
}执行结果
[Running] cd e:\codes\C\myC\test\ g main.cpp -I D:\software\boost_1_87_0 -o main e:\codes\C\myC\test\main
------------测试boost库安装是否正确------------
ISMILELI
Hello World![Done] exited with code0 in 3.564 seconds总结
本文配置适用于单c/cpp文件执行不适合工程级别配置。仅供学习使用。boost文件可以自由跳转。关于setttings.json中的配置我认为cpp文件的编译指令应有更好的实现方式当前实现放在这个文件不是最佳。后续会更新。欢迎知道的网友留言。