Mac下Visual Studio Code调试C++报错:需指定MIDebuggerPath
Mac下VS Code调试C++报错:无法确定调试器路径的解决方法
在Mac(arm64架构)上使用VS Code调试C++,已配置tasks.json和launch.json,但点击调试按钮时出现以下错误:
Unable to start debugging. Launch options string provided by the project system is invalid. Unable to determine path to debugger. Please specify the "MIDebuggerPath" option
解决步骤
1. 确认LLDB调试器路径
打开终端,执行以下命令获取LLDB的实际安装路径:
which lldb
- 若通过Homebrew安装LLDB,路径通常为
/opt/homebrew/bin/lldb - 系统自带LLDB的路径一般为
/usr/bin/lldb
2. 修改launch.json配置
在launch.json的调试配置项中添加MIDebuggerPath字段,填入上一步获取的LLDB路径。修改后的完整配置如下:
{ "configurations": [ { "name": "C/C++: g++ build and debug active file", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/${fileBasenameNoExtension}", "args": [], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], "externalConsole": false, "MIMode": "lldb", "targetArchitecture": "arm64", "preLaunchTask": "C/C++: g++ build active file", "MIDebuggerPath": "/opt/homebrew/bin/lldb" // 替换为你的lldb实际路径 } ], "version": "2.0.0" }
3. 验证配置
保存修改后的launch.json,重新点击调试按钮,即可正常启动调试。
内容的提问来源于stack exchange,提问作者mathworker21
相关产品推荐
相关产品推荐

