I try to setup helloworld project with vscode and gdb for cpp.
I uses msys2.
It all sets just fine, project compiles and runs, but i have problem with debugging it.
Here my launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/helloworld.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:/msys64/usr/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
and my demo project
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(int argc, char** argv)
{
vector<string> msg {"Hello", "C++", "World", "from", "VS Code!"};
for (const string& word : msg)
{
cout << word << " ";
}
cout << endl;
}
But when i run debug, instead source file it show just empty file, i figure out that new file created in
C:\c\Users\user\projects\helloworld\
so there a problem with path there.
How to fix it?
I use wrong gdb.
You need install other version of gdb:
pacman -S mingw-w64-x86_64-gdb
and use it
"miDebuggerPath": "C:/msys64/mingw64/bin/gdb.exe",