vs code c++编译报错,文件配置错误

程序写好运行时出现midebuggerpath无效,这个怎么设置,按照官网的路径也是无效的

把那几句代码贴出来,看一下

你看看路径字符串是否正确,路径下是否有对应文件

"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"targetArchitecture": "x64",
"program": "${workspaceRoot}/2.cpp",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true
},
{
"name": "C++ Attach (GDB)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"targetArchitecture": "x64",
"program": "${workspaceRoot}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"processId": "",
"externalConsole": false
}
]
}

系统提示Unable to start debugging. Launch options string provided by the project system is invalid. Unable to determine path to debugger. Please specify the "DebuggerPath"option
这个怎么搞

这个应该是要设置miDebuggerPath

{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
//配置名称,将会在启动配置的下拉菜单中显示
"name": "gcc build and debug active file",

// 配置类型,这里只能为cppdbg
"type": "cppdbg",
// 请求配置类型,可以为launch(启动)或attach(附加)
"request": "launch",
// 将要进行调试的程序的路径
"program": "${workspaceFolder}/${fileBasenameNoExtension}.o",
// 程序调试时传递给程序的命令行参数,一般设为空即可
"args": [],
// 设为true时程序将暂停在程序入口处,一般设置为false
"stopAtEntry": false,
// 调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录
"cwd": "${workspaceFolder}",
"environment": [],
// 调试时是否显示控制台窗口,一般设置为true显示控制台
"externalConsole": true,
"MIMode": "gdb",
//"preLaunchTask": "g++", // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "gcc",
"miDebuggerPath": "/usr/share/gdb"
}
]
}

我从网上看来是这个样子的,但是我也会报错,也是因为 miDebuggerPath