Jump to content
  • Advertisement
Sign in to follow this  
Fish Fishes

LIBs vs LoadLibrary()

This topic is 4928 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
I think you're asking about static vs. dynamic linking.

Static linking with libraries is faster, and easier to code for. If you can get away with it, go for static linking.

However, for some things static linking just isn't safe. If you're using libraries or functions that you can't guarantee are supported on the target system, then static linkage isn't really good enough - the program will simply bomb out as soon as you try and run it on such a system. Also, dynamic linking enables you to do some other tricks, like choose your library implementation at run time.

The XP theme code I posted in your other thread loads them dynamically because these functions are not supported at all on any OS other than XP. If it had linked to the xptheme library statically, the program would not run at all on any other platform.

Share this post


Link to post
Share on other sites
Or are you talking about import libraries vs. dynamic loading? In that case I would use the first one where possible (see post above). It's easier to code since the compiler takes care of the correct calling and you don't have to manage the function pointers for the entry points by yourself.

Share this post


Link to post
Share on other sites
Using .lib files are safe and easy when you're using your own DLLs (although then you may want to use LoadLibrary), and is also pretty safe for common system DLLs (opengl32.lib and winmm.lib are two that come to mind from my own projects).

For fancy stuff that's only supported on some systems (like Sandman's example), you should use LoadLibrary.

In any case, their speed will not matter - your linking should not be happening in speed-critical sections and the actual calling of functions is the same speed.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!