Diference between Libs and Dlls

Started by
2 comments, last by Spudder 19 years, 7 months ago
Hi there. Diference between Libs and Dlls I'm mostly trying to find out about performance diferences, since i looked some old posts and there are a lot of them talking about all the other advatages of using either Libs or Dlls. I'de like to know wich one is faster, at run time, and how much faster is one then the other, numbers would be great, feel free to neglect the load overhead, since that doesn't matter much to me. I'de also be interested in your opinion about other subjects not mentioned in this post, but related, that you may feel somehow should be brought to my attention. Thank you.
"Follow the white rabbit."
Advertisement
Static libs are compiled into the exe. DLLs are not. As far as performance goes, you really can't tell the difference. You just need to be more careful when using DLLs.
The speed only matters when you're making thousands of calls to the DLL/lib per frame. It amounts to one (possibly two) extra jump instructions, which will have little performance impact.

Use a lib if you just want to split up your code a bit more. Use a DLL if you want to load at runtime (LoadLibrary() et al), you want to be able to update the DLL seperately from the exe, or you want to keep the exe file size down (although I wouldn't worry about this much)
DLLs are a handy way of being able to plug-in new code into your game/app without having to recompile your client application if you dynamically link to the DLL with LoadLibrary() etc as long as the interface which your client app uses hasn't changed. Just take the Half-Life game which lets you make any changes you like to the game code, all you need to do is recompile the dll and put it in the right directory and the engine will automatically run your modified dll without any fuss, this wouldn't be possible with a static lib.

You could use a static library for code which you know isn't going to change - perhaps a small library of utility functions you written, this saves you from having to add the code and compile it during every time, which can make build times faster, but then any changes to the code inside the static lib will result in a client app recompile as well - not good if the code inside the lib changes often in which case use a dynamically loaded dll instead.

This topic is closed to new replies.

Advertisement