c++ - 调试基于 Linux 的 C++ 代码 visual studio 代码时出现问题

标签 c++ linux visual-studio-code

我正在尝试在 Linux - Ubuntu 的 visual studio code 中调试我的代码。我已经根据规范配置了调试配置。但是在尝试调试时出现以下错误。

=thread-group-added,id="i1" GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/. For help, type "help". Type "apropos word" to search for commands related to "word". =cmd-param-changed,param="pagination",value="off" 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).

   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"
                    }
                },
            ]
        }

最佳答案

因为并非所有库(.a、.so)都链接到您的项目。我有同样的问题。当遇到对未链接的库的库调用时,gdb 会输出此错误。

关于c++ - 调试基于 Linux 的 C++ 代码 visual studio 代码时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48089861/

相关文章:

javascript - 如何阻止 VS Code 建议我从转译文件中导入代码?

c++ - 单个 Visual Studio 项目中的多个 C++ 主文件

c++ - 防止 ZMQ c++ 调用 rand()

python - 我有几个 Linux 命令,我想在 Windows 机器上运行。如何在 Windows 上从 Python 运行 Linux 命令

python - 防止执行脚本时打开终端(crontab)

javascript - 是否有内置的不和谐功能允许类别 channel 的 'tagging' ?

c++ - 用于稀疏酉矩阵的最佳 C++ 矩阵库

c++ - _endthreadex(0) 挂起

c - 是否有任何文档可用于 glibc 6 的动态链接器函数?

node.js - 在 azure 上部署应用程序期间,Visual Studio 总是卡住