Problem for linked sdl2 libs

hey guys, im new to linux and im trying create a c program that include SDL2 libs but for some unknown reason i get error during compiling with sdl function, i explain myself :

  • I have download all requires developper SDL2 packages with this command

     ` apt-get-install  libsdl2-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-mixer-dev 
      libsdl2-net-dev libsdl2-ttf-dev`
    
  • In my c file i put this at the top :

#include <SDL2/SDL.h>

  • to compile my code with gcc i linked it with SDL2-config to add all missing libs etc
    command i use :

gcc main.c -o main.o $(sdl2-config --cflags)

  • finally this is the code i want to compiled

      int main(int argc, char *argv[])
      {
          SDL_Init(SDL_INIT_VIDEO); 
       
          SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE); 
       
          SDL_Quit();
       
          return EXIT_SUCCESS; 
      }
    

-this is the errors i get
`

main.c: In function ‘main’:
main.c:19:5: warning: implicit declaration of function ‘SDL_SetVideoMode’; did you mean ‘SDL_GetVideoDriver’? [-Wimplicit-function-declaration]
19 | SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE); // Ouverture de la fenĂȘtre
| ^~~~~~~~~~~~~~~~
| SDL_GetVideoDriver
main.c:19:36: error: ‘SDL_HWSURFACE’ undeclared (first use in this function); did you mean ‘SDL_SWSURFACE’?
19 | SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE); // Ouverture de la fenĂȘtre
| ^~~~~~~~~~~~~
| SDL_SWSURFACE
main.c:19:36: note: each undeclared identifier is reported only once for each function it appears in

`
it seem like some libs has not been add or are missing, why ?

im sorry for the long explanation but it is for understanding purposes, thanks .

Because you’re trying to use legacy SDL1 APIs. SDL2.x is not compatible with SDL1.x. SetVideoMode now become CreateWindow etc. MigrationGuide - SDL Wiki'

1 Like