gpt4 book ai didi

c++ - 使用gdb调试时如何解决VS Code中: "launch : program "executable. out"does not exist"

转载 作者:行者123 更新时间:2023-11-28 01:14:34 26 4
gpt4 key购买 nike

我正在学习 VScode 团队的教程: https://code.visualstudio.com/docs/cpp/config-wsl#_debug-helloworldcpp

我已经运行并构建了另一个 C++ 项目。它编译但项目在运行时崩溃,所以我决定调试它。

所以我想调试并按照这个很好的教程所建议的那样使用 gdb。当我使用“F5”执行调试时,我有 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": "g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "executable.out",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}

我修改了“程序”部分以放置我的可执行文件 (executable.out) 的名称,它位于“workspaceFolder”中

所以我不明白我在执行“F5”时收到的错误消息:

launch : program "executable.out" does not exist

enter image description here

有人可以向我解释如何解决吗?在发布这个问题之前我想了很多。

非常感谢。最好的问候

最佳答案

程序中使用绝对路径:

"program": "${workspaceFolder}/executable.out"

关于c++ - 使用gdb调试时如何解决VS Code中: "launch : program "executable. out"does not exist",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59127441/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com