You just have to include the libraries your linking to in the command line options. For SDL this should work (basic SDL):
gcc source_code.c -lSDL -lpthread
This will produce a.out of your file. If you use something like the SDL_image library,
gcc source_code.c -lSDL -lSDL_image -lpthread
If you are using opengl as well, then probably something like this,
gcc source_code.c -lGL -lGLU -lSDL -lpthread
should work. etc.. hope this helps
(you should include the -lpthread with SDL)