'SDL driver fails when starting debug session on remote linux

On Win10, I have a visual studio c++ project for linux that uses the SDL2 driver. The target machine is a VirtualBox - Ubuntu 18.04.

I configured Visual studio to compile remotely on the target system, which works fine. Running the output file from console on the remote machine shows that SDL uses the XServer:

SDL_GetCurrentVideoDriver: x11

When I start debugging from visual studio (starts GNU debugger gdb on remote side):

SDL_Init error: No available video device
SDL_GetCurrentVideoDriver: null

starting gdb from remote anyway works as expected:

gdb ./myProgram
(gdb) run

But this doesn't let me debug in visual studio, which i'm looking forward to. Any idea ?



Solution 1:[1]

In Project Settings:

Configuration Properties -> Debugging -> Pre-Launch Command -> export DISPLAY=:0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 deafjeff