Here is my simple program
#include <SDL2/SDL.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
SDL_Window *window = NULL;
if(SDL_Init(SDL_INIT_VIDEO) != 0)
{
SDL_Log("ERROR : SDL Initialization > %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
//Program
window = SDL_CreateWindow("My Viewer",SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_SHOWN);
if(window == NULL)
{
SDL_Log("ERROR : SDL Window creation > %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
SDL_Delay(5000);
SDL_DestroyWindow(window);
SDL_Quit();
return EXIT_SUCCESS;
}
When running the command line :
gcc main.c -o prog $(sdl2-config --cflags --libs) && ./prog
it display :
error: XDG_RUNTIME_DIR not set in the environment.
INFO: ERROR : SDL Initialization > No available video device
I search many forum and tried what they told us to do but nothing work.
I uninstall and re install (manually and also with command line) SDL2, change the env var "export DISPLAY=:0.0" or "export DISPLAY=:1", tried this forum but nothing seems to change.
I'm running this code in bash Ubuntu with WSL2.