Difference between DLL and LIB

Programming, for all ages and all languages.
Post Reply
newbiee

Difference between DLL and LIB

Post by newbiee »

hi
I m a newbie with the windows programming, recently i have started with DLL, but i m not able to figure out what is the difference between a .DLL and .LIB File ???
anubis

Re:Difference between DLL and LIB

Post by anubis »

a .DLL is a compiled file like a .EXE. A .lib file is usually is companion file that contains the exported functions of the .DLL.
.lib file is usually used by the compiler to determine which functions the .dll provides.

when one is using a .dll file it is not necssary to have a .lib file if one knows which functions the .dll provides. .lib file is usually for the help of te compiler. ;D
Tim

Re:Difference between DLL and LIB

Post by Tim »

A .LIB file can be an import library for a DLL, or it can be a library in its own right. In either case it provides the names of functions for the linker, so that you can use its functions. The difference is that the functions defined in an import library redirect to the implementations in the corresponding DLL, whereas a true library will contain the implementations in the .LIB itself, and they will get linked inside the EXE.
newbiee

Re:Difference between DLL and LIB

Post by newbiee »

Maybe i didnt get it, may be i gt it, but let me clearify what i understand, a DLL file is like a EXE file, which contains some function which can be shared ??? m i right ??

A LIB File also contains the shared function right ???
the main difference is that a LIB file is compiler specific ???

also one more question, if i m using a .LIB file will it be linked to the program, i know that we have to sand the .DLL file with the EXE, do we have to send the .LIB file with the exe so that it can run, or does the .LIB file gets linked to the EXE itself ???

-thanks :-)
Tim

Re:Difference between DLL and LIB

Post by Tim »

The .LIB file gets linked inside the EXE. This is the main difference between LIBs and DLLs.
anubis

Re:Difference between DLL and LIB

Post by anubis »

A DLL has a list of functions that are exported. Exported means an external program can use those functions either by loading the DLL into memory or use them directly if DLL is already loaded.

Windows (in 32-bit) also exports itself as a dll and resides in Kernel32.dll, User32.dll and GDI32.dll.

DLL are made in a similar way that EXE are made with the only difference that an EXE may be a standalone application whereas a DLL may be shared between many applications simulatneously. Consider such a scenario where u r making a suite of applications each using a specific class many times during usage. Here instead of using the same class in all the applications making them bloat, it is much more wise to include a dll which all the applications use simulataneously at leisure.

Usually one cannot query a DLL to know which functions it carries and what parameters those functions have. A LIB file usually accompanies a DLL for the use of the developer to know which functioons r exported. To draw an analogy they are like a .h header file accomaning a source .cpp file. For dll without a .lib there are utilities like Dll2Lib, to generate a lib when u have just a dll present.
Post Reply