我尝试使用vscode和gdb为cpp设置helloworld项目。
我使用msys2。
这一切都很好,项目可以编译并运行,但是我在调试时遇到问题。
这里是我的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
}
]
}
]
}
和我的演示项目
#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;
}
但是当我运行调试时,源文件显示的只是空文件,我发现在]中创建的新文件>
C:\ c \ Users \ user \ projects \ helloworld \
所以那里的路径有问题。
如何解决?
我尝试使用vscode和gdb为cpp设置helloworld项目。我使用msys2。一切都很好,项目可以编译并运行,但是我在调试时遇到问题。这是我的launch.json {//使用...
我使用了错误的gdb。