Sign in to follow this  
White Rabbit

Diference between Libs and Dlls

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this