I just switch from Netbeans to visual studio code, and i cannot debug c++, the error was Unable to start debugging. Launch options string provided by the project system is invalid. Unable to determine path....
I tried to follow the c/c++ debug guide from visual studio code website that i searched from google, but it failed to run the application, but i can compile c++ from Ctrl + Shift + B so my task.json file is correct, so here are my task.json file and launch.json file.
{
//Task.json
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "g++",
"isShellCommand": true,
"args": ["-pipe", "-std=c++14", "${fileBasename}", "-lm"],
"showOutput": "always"
}
//Launch.json
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"linux": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
},
I just fixed it by doing the following (under windows)
Installed TDM-GCC MinGW Compiler from https://sourceforge.net/projects/tdm-gcc/?source=typ_redirect use default installation path options.
Added these folders to PATH environment variable
C:\TDM-GCC-64\bin
C:\TDM-GCC-64\gdb64\bin
"windows": {
"MIMode": "gdb",
"miDebuggerPath": "C:/TDM-GCC-64/gdb64/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
Remark: Like others had mentioned you should add the -g option in your tasks.json args so that the executable will be built with debugging information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With