Jump to content
  • Advertisement
Sign in to follow this  
methinks

Question on freeing dynamic loaded dlls

This topic is 3984 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

What would happen if I load the same DLL twice, (using LoadLibrary and GetProcAddress), then removed ONE of them using FreeLibrary? Would the other one still work? I guess my question is really, does windows load each one into memory separately, or does it just point to the same location twice? I did try to write a test case to figure it out, but it's acting strange: even after I call FreeLib, I can still access classes created by the DLL. Is this right? The same questions stand for linux (I'm trying to write cross platform code here) using dlopen, dlsym and dlclose For tools I'm using code::blocks with vc++ 2005 (express) in windows, and g++ 4.4 in ubuntu On the topic of cross-platform code, are there any compiler flags that automatically get put up which identify the platform being compiled for?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by methinks
What would happen if I load the same DLL twice, (using LoadLibrary and GetProcAddress), then removed ONE of them using FreeLibrary? Would the other one still work? I guess my question is really, does windows load each one into memory separately, or does it just point to the same location twice?

Mu. Windows loads the library once, but increments its reference count twice. If you call FreeLibrary only once, the reference count is only decremented once, and the library is not unloaded.

Share this post


Link to post
Share on other sites
Quote:
Original post by methinks
On the topic of cross-platform code, are there any compiler flags that automatically get put up which identify the platform being compiled for?

Windows projects usually have a preprocessor define for WIN32 and/or _WINDOWS

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!