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"
  }
相关推荐
怒放de生命201016 分钟前
IDEA 2025 最新版jrebel 破解
java·ide·intellij-idea
猿小猴子1 小时前
主流 AI IDE 之一的 CodeFlicker 介绍
ide·人工智能
Project_Observer1 小时前
任务条件布局规则如何帮助自动管理任务?
大数据·数据结构·人工智能·深度学习·机器学习·编辑器
lightqjx3 小时前
VS Code 的安装与如何搭建C/C++开发环境?
vscode·c/c++开发工具·vs code安装教程·vs code的使用
bu_shuo3 小时前
Windows电脑使用VSCode远程控制Windows主机方法记录
windows·vscode·ssh·powershell
hhzz3 小时前
JupyterLab、Jupyter Notebook 和 Voilà 的安装与使用指南
ide·python·jupyter
Billy_Zuo3 小时前
Android Studio 打aar包
android·ide·android studio
虎大猫猫3 小时前
JupyterLab的安装与使用完全指南
ide·python·jupyter
码码不爱我4 小时前
Jupyter在Pycharm中出现Connection reset错误调试
ide·jupyter·pycharm
a1117764 小时前
堆叠式流程图编辑器(html 开源)
开发语言·前端·javascript·开源·编辑器·html·流程图