4

I face problem with configuring launch.json file on my Windows and it shows error message

Debug adapter process has terminated unexpectedly.

I have set up "MinGW" and configured g++ compiler, and now Visual Studio Code compiles correctly. When I press Ctrl+Shift+B, it creates a.exe file in project folder.

My launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch (Windows)",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceRoot}/a.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": false
        },
        {
            "name": "C++ Attach (Windows)",
            "type": "cppvsdbg",
            "request": "attach",
            "processId": "${command.pickProcess}"
        }
    ]
}

My task.json file:

{
    "version": "0.1.0",
    "command": "g++",
    "isShellCommand": true,
    "showOutput": "always",
    "args": ["-std=c++11","-g", "main.cpp"]
}

1 Answer 1

3

It may be wrong, but I suppose you need to compile your .c/.cpp file with microsoft cl.exe compiler (not by gcc) to use microsoft debugger on it. To setup paths for cl, call the vcvarsall.bat with parameter x86 or x64 (depends on what you need) and then cast cl to your source file. By the way check this article (the part with json configuration exactly) to ensure, where you did wrong https://www.40tude.fr/blog/how-to-compile-cpp-code-with-vscode-cl/

Sign up to request clarification or add additional context in comments.

1 Comment

there's nothing wrong with debugging non-MS files in VS code because it's just an editor and will call the corresponding debugger (gdb, lldb, whatever...) code.visualstudio.com/docs/cpp/config-mingw

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.