我正在尝试在Linux - Ubuntu中使用Visual Studio Code调试我的代码。我已经按照规范配置了调试配置。但是在尝试调试时,我遇到了以下错误。
=thread-group-added,id="i1" GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1版权所有(C) 2016自由软件基金会。许可证GPLv3+:GNU GPL第3版或更高版本。http://gnu.org/licenses/gpl.html 这是免费软件:您可以自由更改和重新发布它。 在法律允许的范围内,没有保修。输入“show copying”和“show warranty”以获取详细信息。这个GDB被配置为 “x86_64-linux-gnu”。输入“show configuration”查看配置 详细信息。有关错误报告说明,请参见: http://www.gnu.org/software/gdb/bugs/。在网上查找GDB手册和其他文档资源: http://www.gnu.org/software/gdb/documentation/。需要帮助,请输入 “help”。输入“apropos word”搜索与“word”相关的命令。 =cmd-param-changed,param=“pagination”,value=“off”由于共享库事件而停止(未添加或删除任何库)加载 '/lib64/ld-linux-x86-64.so.2'。符号已加载。[下属1(进程 18634)退出代码为0177]程序 '/home/source/src/.libs/main'以代码177(0x000000b1)退出。
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": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"targetArchitecture": "x64",
"program": "${workspaceFolder}/src/.libs/main",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb"
}
},
]
}
Stopped due to shared library event (no libraries added or removed) Loaded '/lib64/ld-linux-x86-64.so.2'. Symbols loaded. [Inferior 1 (process 18634) exited with code 0177] The program '/home/source/src/.libs/main' has exited with code 177 (0x000000b1).
。在这里,你似乎正在尝试在VS编译下加载、编译或运行Linux 共享对象库。我不知道在WSL下这样是否可行,但你不能指望VS(至少我使用的版本)使用.so
而不是Windows的.dll
。 - David C. Rankin.so
文件。这意味着我无法在VS下调试使用.so
文件的程序,对吗? - HMDgcc
,因此你可以使用gcc
构建你的代码(使用-g
选项生成gdb
符号文件),然后你可以使用gdb
进行调试。 - David C. Rankin