Reputation: 83
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"]
}
Upvotes: 4
Views: 3507
Reputation: 46
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/
Upvotes: 3