首页 > 解决方案 > Visual Studio Code 中的调试器显示神秘的错误窗口

问题描述

我正在尝试为 C++ 设置 Visual Studio 代码,如该视频所示: https ://www.youtube.com/watch?v=DIw02CaEusY&t=701s 。我遇到的问题是在配置调试器时,

每当我尝试调试项目时,我都会收到一个奇怪的错误窗口:

“preLaunchTask 'g++.exe build active file' 以错误代码 1 终止”。

我已尝试研究该错误,但没有显示任何有用的信息。我曾尝试在 StackOverflow 上搜索类似问题,但运气不佳。

这是我的 tasks.json 文件中的代码:

    {
       "version": "2.0.0",
       "tasks": [
           {
               "label": "echo",
               "type": "shell",
               "command": "g++ -g main.cpp",
               "group": {
                   "kind": "build",
                   "isDefault": true
               }
           },
           {
               "type": "shell",
               "label": "g++.exe build active file",
               "command": "C:\\MinGW\\bin\\g++.exe",
               "args": [
                   "-g",
                   "${file}",
                   "-o",
                   "${fileDirname}\\${fileBasenameNoExtension}.exe"
               ],
               "options": {
                   "cwd": "C:\\MinGW\\bin"
               }
           }
       ]
   }

这是我的 launch.json 文件:

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

标签: c++visual-studio-code

解决方案


推荐阅读