配置vscode 的C/C++ 环境
1、首先下载mingw,以及vscode
2、添加mingw的环境变量
3、配置vscode文件
按 ctrl + shift + p , 输入configuration, 选择 edit configuration
{ "configurations": [{ "name": "Win32", "includePath": [ "${workspaceFolder}/**" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "compilerPath": "D:\\programme installation 2\\mingw\\mingw64\\bin\\g++.exe", "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "clang-x64" }], "version": 4 }
然后ctrl + shift + p, 输入task ,选择 default build task
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "type": "shell", "label": "g++.exe build active file", "command": "D:\\programme installation 2\\mingw\\mingw64\\bin\\g++.exe", "args": [ "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe" ], "options": { "cwd": "" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true } } ] }
最后按 ctrl + shift + p,输入launch,选择launch.json
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "preLaunchTask": "g++.exe build active file",//调试前执行的任务,就是之前配置的tasks.json中的label字段 "type": "cppdbg",//配置类型,只能为cppdbg "request": "launch",//请求配置类型,可以为launch(启动)或attach(附加) "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",//调试程序的路径名称 "args": [],//调试传递参数 "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true,//true显示外置的控制台窗口,false显示内置终端 "MIMode": "gdb", "miDebuggerPath": "D:\\programme installation 2\\mingw\\mingw64\\bin\\gdb.exe", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }
以上的文件配置代码可以直接复制。
程序可以运行。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律