1

I'm just trying to test my SDL installation (I've used apt install libsdl2-dev), I've included the library and tried this code to see if it works, I even got no errors and the return of SDL_Init is successful, but I can't see any window showing up :

    #include <stdio.h>
#include <SDL2/SDL.h>

int main()
{
    printf("%d", SDL_Init(SDL_INIT_EVERYTHING));
}

this is the compilation flag that I'm using :

gcc -c lol.c `pkg-config sdl2 --cflags`

I've tried also this but it doesn't work too :

gcc -o program_name lol.c -std=c99 -I/usr/include/SDL2 -lSDL2main -lSDL2
  • 1
    In addition to the already provided answers, consider taking a look at [this tutorial](http://www.sdltutorials.com/sdl-tutorial-basics). If you can overlook the fact that it is implemented in C++, there are useful concepts that may be of help for understanding what to search for later on at the [api documentation](https://wiki.libsdl.org/SDL2/CategoryAPI) (or at least it was a nice kickstart for me, and I am myself using C). – dandev486 Jun 18 '23 at 21:55

1 Answers1

5

Your code is working fine. SDL_Init doesn't create any windows or anything like that, it just sets up some background state needed for the rest of the library to work.

You need SDL_CreateWindow to create a window (Sdl can be used with multiple windows or no Windows at all if you like).

Cubic
  • 14,902
  • 5
  • 47
  • 92