Datow King
Datow King

Reputation: 161

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

I am trying out Targeting the Windows Subsystem for Linux from Visual Studio. The project builds fine in 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 ==========

I can run it from the bash commandline prompt on Windows:

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

However, when I set a breakpoint to debug it from Visual Studio, I got error:

"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"

I did install gdbserver on the Linux subsystem on Windows. Does anyone know what else I need to make it work? Thanks in advance!

Upvotes: 1

Views: 5375

Answers (1)

stanthomas
stanthomas

Reputation: 1181

Firstly, have you installed gdb on WSL? What does command gdb --version display?

Then recommend you debug in gdb mode, see this topic for details.

And, if you read the comments in the 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

Upvotes: 6

Related Questions