1.安装扩展
扩展中搜索Chinese,安装中文插件,restart重启配置
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-s14sjteD-1658823812348)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719173206100.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/6bf283631dea43f888ec3d87d3a7860f.png)
同时安装c++扩展
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AIWzMP5F-1658823812349)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719181808193.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/df329def03e54bd9afce4674d109bf3a.png)
安装C/C++ Compile Run插件
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-J5svP9oW-1658823812350)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719181830420.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/6f4c9a834b95498aa945d5219675a4e3.png)
2.下载TDM-GCC
链接:https://pan.baidu.com/s/1cR1VkOnkitFUtwznm2N6oQ
提取码:bwez
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fWdFXei3-1658823812350)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719173408042.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/92158ae9223443518902b625dc320084.png)
在_installer文件夹内,选择应用程序文件
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AcWqjOv2-1658823812351)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719173424070.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/cd28682ec36346d38cd91df1273ec9fc.png)
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-uAOW1Rol-1658823812351)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719180606125.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/9dc6940aef534c9683ce33fc8e09e515.png)
点击create开始安装
修改安装路径(一定要记住)
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-MZlTeyJU-1658823812351)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719180633531.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/9c6223de10dd42328d3869f291aeec9e.png)
这里注意要勾上第一个gcc,可以都勾上
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-WwIwWowU-1658823812352)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719180655379.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/ffddce3f2dce40568af6b862cfd7dde8.png)
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-eM1KGuXy-1658823812352)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719180721582.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/75397eed7bb648e1a2b82d33e526a158.png)
点击install安装即可
3.配置TDM-GCC环境
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TSz6083O-1658823812352)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719180822988.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/690a550b4f894822bf3739f652309789.png)
进入环境变量
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-gTgCcbUH-1658823812352)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719180848997.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/f2e7b7e6b52e4dbfa9fe20df0501cd71.png)
点击Path,将刚才的安装路径加入到Path内(如果已经加进去了就不用动了)
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jQfdImbm-1658823812353)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719180914085.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/f95173df921a462daaf17d6306144514.png)
4.编写vscode环境配置文件
用vscode随意打开一个文件夹
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-0i4HJ0e6-1658823812353)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719181020368.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/79270a8043d54b3594375e4a6ff3740b.png)
创建.vscode文件夹
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-KFNukPcE-1658823812353)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719181040808.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/1a62a23430a547928f327c3193edf2b1.png)
1.创建tasks.json文件
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-LlNDQ1Ai-1658823812353)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719181115625.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/5d820a8ab896423ebdbeab39be075310.png)
文件内容:
{
"version": "2.0.0",
"tasks": [{
"label": "g++",
"command": "g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.exe"
],
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
2.创建launch.json文件
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-j9zlIN27-1658823812353)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719181207928.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/df7fc55d3b184a989654a0310866e434.png)
文件内容:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch", // 配置名称,将会在启动配置的下拉菜单中显示
"type": "cppdbg", // 配置类型,这里只能为cppdbg
"request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加)
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",// 将要进行调试的程序的路径
"args": [], // 程序调试时传递给程序的命令行参数,一般设为空即可
"stopAtEntry": false, // 设为true时程序将暂停在程序入口处,一般设置为false
"cwd": "${workspaceRoot}",// 调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录
"environment": [],
"externalConsole": true,// 调试时是否显示控制台窗口,一般设置为true显示控制台
"MIMode": "gdb",
"miDebuggerPath": "C:\TDM-GCC-64\bin\gdb64.exe",// miDebugger的路径,注意这里要与MinGw的路径对应
"preLaunchTask": "g++", // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
5.编写与执行cpp文件
编写一个cpp文件
在文件->首选项->设置->扩展找到Compile Run config
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-pmE5a9Dr-1658823812354)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719181927595.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/ec382f3625b4401e8b0f12d91b821278.png)
勾选Run-in-external-terminal,就可以在小黑框运行啦
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-xOwoDjIi-1658823812354)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719182009918.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/f036b6637d47400a9b74fb421de3c6e1.png)
f5运行cpp文件
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VK8ClzUw-1658823812354)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719181955805.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/ac1b28ed9a204862a5f3af477851cb74.png)
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bq1XhvSu-1658823812354)(C:UsersAdministratorAppDataRoamingTyporatypora-user-imagesimage-20220719182030138.png)]](https://file2.kaopuke.com:8081/files_image/2023061020/24ef74e396c14460b8db09653dcda0f1.png)
最后
以上就是平常大门最近收集整理的关于史上最好用教程——Vs Code 配置c++环境【带有环境安装包】的全部内容,更多相关史上最好用教程——Vs内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复