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 ?
r_sam_14Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wildyCommented:
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)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gashevCommented:
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")
 
0
akalmaniCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.