Am I linking correctly

gcc main.c -lSDL2 -lSDL2main -o drawwindow

In function main': main.c:(.text+0xeb): undefined reference toSDL_SetVideoMode’
main.c:(.text+0x165): undefined reference to CreateHicolorPixel' main.c:(.text+0x1ea): undefined reference toSDL_UpdateRect’
collect2: error: ld returned 1 exit status

Yes you are linking correctly, but your code uses SDL1.2 functions that are not available in SDL2. might be helpful to port SDL 1.2 code to SDL2

If you’re new to SDL, the tutorials at should help (they’re for SDL2, no reason to learn SDL1.2 first)

1 Like