I am having problems with initializing sdl.


int main(int argc, char *argv[])
    return 0;

returns error:

/usr/bin/ld: /tmp/cc7hqwQm.o: in function `main':
testing.c:(.text+0x19): undefined reference to `SDL_Init'
collect2: error: ld returned 1 exit status

This mean you haven’t given your compiler the SDL2 library so it doesn’t know where to look for the SDL_Init function.

On Linux with Clang and GCC, you should just be able to add -lSDL2 in the command you use to compile and it should work (if you have SDL2 installed ofc).

1 Like