Am I linking correctly

gcc main.c -lSDL2 -lSDL2main -o drawwindow

https://pastebin.com/1m603Dw6

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.

https://wiki.libsdl.org/MigrationGuide might be helpful to port SDL 1.2 code to SDL2

If you’re new to SDL, the tutorials at http://lazyfoo.net/tutorials/SDL/index.php http://twinklebear.github.io/pages/sdl2/ should help (they’re for SDL2, no reason to learn SDL1.2 first)

1 Like