ERROR: Unable to start debugging. Unexpected GDB output from command “-exec-run”. During startup program exited with code 0xc0000139

  Kiến thức lập trình

So, I am new to c++, use vscode and Windows 11 and installed MinGw and have currently the problem that when running simple programs like hello world nothing gets printed. Instead a .exe file is created with the same name as my program. The Terminal just prints:

  • Executing task: C/C++: g++.exe build active file

Starting build…
cmd /c chcp 65001>nul && C:msys64ucrt64bing++.exe -fdiagnostics-color=always -g C:UsersnoahmDesktopVs_Codeprogrammingcppgodisgood.cpp -o C:UsersnoahmDesktopVs_Codeprogrammingcppgodisgood.exe

Build finished successfully.

  • Terminal will be reused by tasks, press any key to close it.

and in the debug console the error:
ERROR: Unable to start debugging. Unexpected GDB output from command “-exec-run”. During startup program exited with code 0xc0000139.

my tasks.json looks like this:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\msys64\ucrt64\bin\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

and my launch.json file which was not there in the first place and thus had to be made by myself:

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

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

this launch.json, of which i dont know whether you can just copy and paste it, I got from a post of a person with similar problems as I do: ERROR: Unable to start debugging. Unexpected GDB output from command “-exec-run”. Unable to find Mach task port for process-id 1401

New contributor

Max Mustermann is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

4

LEAVE A COMMENT