无法开始调试。程序路径“/home/student/Documents/Visual Studio Code/rectangle”丢失或无效。“
我的launch.json看起来像这样:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"miDebuggerPath": "/usr/bin/gdb",
"targetArchitecture": "x64",
"program": "${workspaceRoot}/rectangle",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": []
},
{
"name": "C++ Attach (GDB)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"miDebuggerPath": "/usr/bin/gdb",
"targetArchitecture": "x64",
"program": "${workspaceRoot}/rectangle",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": []
}
]
}我的C++程序是这样的:
#include <iostream>
using namespace std;
int main()
{
double length, width, area;
cout << "Enter the length: ";
cin >> length;
cout << "Enter the width: ";
cin >> width;
area = length * width;
cout << "The area is " << area << endl;
return 0;
}发布于 2016-05-25 03:23:35
上面提到的“矩形”文件是你的C++源代码吗?
如果是这样的话,按照惯例,它应该被重命名为"rectangle.cpp“,然后编译成一个二进制/可运行的程序--可以命名为"rectangle”。
据我所知,您必须使用VSCODE外部编译器,但可以设置一个编译任务(如果您觉得很高级,还可以设置一个文件监视器和一个问题匹配器)来自动执行编译过程。
发布于 2017-07-27 23:04:19
你是同时安装Cygwin和minGW,还是只安装Cygwin?
在上述两种情况下,请确保VSCODE调用minGW的g++和gdb,您只需添加minGW的绑定路径,并从系统环境中删除Cygwin的绑定路径即可。因为Cygwin构建的exe依赖于cygwin1.dll,而cygwin1.dll不是纯的win exe,所以gdb不能很好地使用这个exe。
https://stackoverflow.com/questions/37405975
复制相似问题