• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

About DLL

When we create a source for Dll and compile it we get a .dll and .lib files,now when do we use .dll or .lib in our application ?
1 Solution
When you compile a DLL you get also a lib that is used for early binding.

With the lib you can #include a file declaring the dll function, add the lib to your project and build. So you don't have to call LoadLibrary, GetProcAddress, etc. but you still need the DLL: when you run your exe, it looks for the dll using the standard search algorithm (first in the dir of the exe, then in system, then in the path)
If you want to use .lib file you add in your project .lib file and include file for .lib . In include file declare types,function, classes , source code their be where in .lib file.
If you want to use .dll file you have 2 way.

1) use function LoadLibrary for load .dll in memory;
GetProcAddress for functions that you want to use;
and FreeLibrary for free memory and end work with dll.
It's evident call .dll.

2) Unevident .dll

You in include file use
#pragma comment(lib,"YourLib.lib")
Hi !!
  DLL is used whenever u want u r application exe size to be small.
There are 2 ways for linking u r DLL
1)Implicit linking
   Here while compiling u r application u give u r .lib file and include the decalration in u r application and call it as a normal function. The DLL has to be dumped in system directory. Because the default directory is set to that.
2)Explicit linking
  Here no need to have a .lib file when compiling u r application.
  But u have to use but u have to use LoadLibrary() to load the DLL and FreeLibrary() to unload the DLL. To get the pointer to the function u have to use GetProcAddress() and call the function through that pointer. This has more advantage than the implicit because u can load the DLL anytime and unload the DLL at anytime. But for the implicit linking the DLL will always be loaded with u r application.

Hope this helps !! any more clarification, always welcome

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now