解决VSCode出现“launch: program ...... does not exist”的问题和“miDebuggerPath“.... does not exist的问题

这个问题困扰了我很久,终于在官方文档上找到了答案,网上有很多版本,我都试过了,没有解决我的问题,可能是我自己没仔细看吧?废话不多说上图?

launch.json.文件

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "g++.exe - Build and debug active file",
      "type": "cppdbg",
      "request": "launch",
      "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${fileDirname}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "gdb",
      "miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ],
      "preLaunchTask": "C/C++: g++.exe build active file"
    }

注意1:“miDebuggerPath”:这里的路径不要在 设置环境变量 哪里复制,应该在这里

在这里插入图片描述

鼠标右击gcc-

复制文件夹地址,用这个,路径"C:\msys64\mingw64\bin\gdb.exe"当然是你自己电脑的对应位置

tasks.json文件:

{
  "tasks": [
    {
      "type": "cppbuild",
      "label": "C/C++: g++.exe build active file",
      "command": "C:/msys64/mingw64/bin/g++.exe",
      "args": ["-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe"],
      "options": {
        "cwd": "${fileDirname}"
      },
      "problemMatcher": ["$gcc"],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "detail": "compiler: C:/msys64/mingw64/bin/g++.exe"
    }
  ],
  "version": "2.0.0"
}

注意:2,该preLaunchTask设置用于指定启动前要执行的任务。确保它与tasks.json文件label设置一致。

注意:3,写文件明的时候不要用中文

评论 21
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值