SDL Question.

Started by
3 comments, last by superkent 17 years, 11 months ago
Hello, Quick question about SDL. Off the bat Im sorry if this is a double post. I was going through Lazy Foo's SDL tutorials (props on them they are quit good!), and need to know what "-lmingw32 -lSDLmain -lSDL" means? I know it tells the linker where to find the SDL librarys etc, but Im one that has trouble doing something "because thats just how you do it." If anyone can tell me exactly what I am telling the linker that would be great! I want to know incase in the future I need to add to this line, I at least know what it is doing. Thanks.
Advertisement
Actually, it doesn't tell the linker where to find them - it tells the linker which ones to use. The example you've given tells the linker to use the "mingw32", "SDLmain" and "SDL" libraries. The "-l" at the beginning just means "link to this library."

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

I'm having problems seeing what exactly you don't understand. Is it specific to SDL, or you just want to know what "libraries" and "linking" is? Anyway, if you have installed SDL correctly, you will have the files SDL.a and SDLmain.a in your libraries directory(.lib extensions for other compilers). Those files contain already compiled code(binary) for SDL routines like SDL_SetVideo(). For example, you call SDL_SetVideo() from within your program, but where's the code for it? Not in "SDL.h", that contains only the interface, not the implementation. That's exactly what this line does. The compiler compiles your program, and then the linker links the result with the specified libraries so that the resulting .exe will run correctly.

Those are command line arguments for the linker program. The dash-letter-word thing is a Unix convention. Anyway, the lowercase l here indicates "this argument specifies a library that should be linked in", and the word gives the name of the library.
Thanks!

This topic is closed to new replies.

Advertisement