Reputation: 8397
I am new to SDL, and I am just curious why does sdl use static and dynamic libraries? I mean, what functions are in sdl.dll, and why is it linked dynamically instead of statically? Thanks.
Upvotes: 4
Views: 1462
Reputation: 54999
SDL.dll
contains implementations of all of the functions that you use from SDL, such as SDL_Init()
and SDL_SetVideoMode()
. It's linked dynamically to allow drop-in replacement of the library with a newer version, without breaking compatibility with existing applications—the SDL interface does not change nearly as often as the implementation. Dynamic libraries provide decoupling between interface and implementation, at the cost of whatever it takes to load them dynamically: searching for a file, loading it, complaining if it's not available, and so on.
An application is more modular using dynamic libraries, and the executable will tend to remain small. It is possible to link statically against SDL, under which circumstances the size of your executable will include the (modest) size of the SDL library, and upgrading to a newer version of SDL will require recompiling your application.
Upvotes: 5