VScode多文件编译/调试配置

之前都是在Visual Studio写C/C++,最近想换到VScode,折腾半天把launch.json和tasks.json配好了(虽然不懂为什么,但确实能用了),在此做个记录。

VScode配置C++环境参考资料:12

多文件参考资料:123

环境:win10

launch.json如下

复制代码
{
    "configurations": [
      {
        "name": "C/C++: g++.exe build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceFolder}\\${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "miDebuggerPath": "E:\\mingw64\\bin\\gdb.exe",
        "setupCommands": [
          {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
          },
          {
            "description": "Set Disassembly Flavor to Intel",
            "text": "-gdb-set disassembly-flavor intel",
            "ignoreFailures": true
          }
        ],
        "preLaunchTask": "C/C++: g++.exe build active file"
      }
    ],
    "version": "2.0.0"
  }

tasks.json如下

复制代码
{
    "tasks": [
      {
        "type": "cppbuild",
        "label": "C/C++: g++.exe build active file",
        "command": "E:\\mingw64\\bin\\g++.exe",
        "args": [
          "-fdiagnostics-color=always",
          "-g",
          "${workspaceFolder}/*.cpp",
          "-o",
          "${workspaceFolder}\\${fileBasenameNoExtension}.exe"
        ],
        "options": {
          "cwd": "${fileDirname}"
        },
        "problemMatcher": ["$gcc"],
        "group": {
          "kind": "build",
          "isDefault": true
        },
        "detail": "Task generated by Debugger."
      }
    ],
    "version": "2.0.0"
  }
相关推荐
梦游钓鱼3 小时前
vscode通过设置ctrl+鼠标滚轮设置终端字体大小
ide·vscode·编辑器
暮色驶过苍茫3 小时前
VSCode 自动更新问题解决记录
ide·vscode·编辑器
春蕾夏荷_7282977255 小时前
vscode 创建第一个python程序
vscode·python
星空6 小时前
vscode开发环境配置
ide·vscode·编辑器
Zww08917 小时前
idea配置注释模板
java·ide·intellij-idea
IOFsmLtzR8 小时前
Visual Studio 中的 Agent:内置 Agent 和自定义 Agent
ide·visual studio
深挖派8 小时前
PyCharm 2026.1 全版本安装配置与全功能环境搭建 (保姆级图文教程)
ide·python·pycharm
不明觉厉二十年9 小时前
pytest+pywinauto+pycharm制作mobaxterm 字符串快捷发送器 Demo
ide·pycharm·pytest
环黄金线HHJX.20 小时前
Tuan符号系统重塑智能开发
开发语言·人工智能·算法·编辑器
环黄金线HHJX.1 天前
龙虾钳足启发的AI集群语言交互新范式
开发语言·人工智能·算法·编辑器·交互