如何修复 VSCode C++ 调试设置错误?

问题描述 投票:0回答:0

我按照网上的说明设置了C++环境,使用MinGW编译器进行编译调试。 但是当我尝试进行调试时,我一直面临这个错误。它可以成功编译代码,但不能进行调试。

unable to start debugging unexpected gdb output from command:"-environment-cd" invalid argument

错误在这里

enter image description here

Unable to start debugging, 

这是我在 launch.json 中的设置

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe 建置使用中檔案"
        }
    ]
}

这是我在 tasks.json 中的设置

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe 建置使用中檔案",
            "command": "C:\\MinGW\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "編譯器: C:\\MinGW\\bin\\g++.exe"
        },
    ]
}

这也是我在 c_cpp_properties.json 中的设置

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}",
                "C:\\MinGW\\include",
                "C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include",
                "C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "__GNUC__=5",
                "__cdecl=__attribute__((__cdecl__))"
            ],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}",
                    "C:\\MinGW\\include",
                    "C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include",
                    "C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "gnu++14"
        }
    ],
    "version": 4
}

对于此错误的任何帮助将不胜感激

对于此错误的任何帮助将不胜感激

c++ visual-studio-code debugging gdb mingw
© www.soinside.com 2019 - 2024. All rights reserved.