Sign in to follow this  

Lib file made when creating a .dll

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

When making a .dll in visual studio a .lib file is usually created that can be used to import the objects/functions you exported into the .dll. Does anyone have more info about this .lib? Is it simply the code needed to dynamically link the .dll at runtime or does it contain the same code that the .dll does just in something that can be statically compiled?

Share this post


Link to post
Share on other sites
If you want your exe to statically link to your dll, you'll need to include the generated lib file in your exes additional libraries.
The .lib file basicly tells the compiler where it can find the functions that are implemented in the dll. If you're using dynamic linking (LoadLibrary() and GetProcAddress()) you can just ignore the generated lib.

Share this post


Link to post
Share on other sites
The .lib that is created is known as an "import library". Its job is to do all the dirty work of loading the DLL and finding and exposing the functions that you would normally do yourself through LoadLibrary and GetProcAddress. Technically it doesn't exactly use these functions (it works at load-time, not run-time), but the effect is the same. Sometimes, you're doing really strange, wacky things with plugins and patches and executable sections and whatnot and the import library won't work for you, but in almost all situations it greatly simplifies the task of using a DLL. You do not need to distribute it with your application.

Share this post


Link to post
Share on other sites
Think of hte lib file as a table of contents to your dll. The DLL has the code and teh lib, often called a linker lib to differentiate it from a static lib, has the memory address, or more appropriately the offset to the method your app needs so that when you startup your app the loader can match up your external methods with the ones in teh dll.

Cheers
Chris

Share this post


Link to post
Share on other sites

This topic is 4667 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.

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