无法从 Visual Studio 启动 gdb 以在 Windows 的 Linux 子系统中远程调试 Linux C++ 项目

Could not launch gdb from Visual Studio for remote debugging Linux C++ project in Linux subsystem on Windows

我正在尝试 Targeting the Windows Subsystem for Linux from Visual Studio。该项目在 Visual Studio:

中构建良好
1>------ Rebuild All started: Project: LinuxConsoleApp, Configuration: Debug x64 ------
1>Cleaning remote project directory
1>Validating architecture
1>Validating sources
1>Copying sources remotely to 'localhost'
1>Starting remote build
1>Compiling sources:
1>main.cpp
1>Linking objects
1>LinuxConsoleApp.vcxproj -> C:\...\LinuxConsoleApp\bin\x64\Debug\LinuxConsoleApp.out
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

我可以在 Windows 的 bash 命令行提示符下 运行 它:

linux@windows-bash:/mnt/c/.../LinuxConsoleApp/bin/x64/Debug$ ./LinuxConsoleApp.out
hello from LinuxConsoleApp!

但是,当我设置断点从 Visual Studio 调试它时,出现错误:

"Could not launch gdb. gdb is missing from your system and needs to be installed, please use your system's package manager to install it"

我确实在 Windows 上的 Linux 子系统上安装了 gdbserver。有谁知道我还需要什么才能让它工作?提前致谢!

首先,您是否在WSL上安装了gdb?命令 gdb --version 显示什么?

那么推荐你在gdb模式下调试,.

而且,如果您阅读 original Visual Studio blog about using WSL, you will see that there are some issues around ssh which, if you follow the trail, will take you to this fix

中的评论