John,
DLL = dynamic link library. This means that the library code is not
actually
linked into your executable, but remains in a separate file and is loaded
either
when you start the executable, or can actually be loaded on-request by the
program.
DLLs are somewhere between the .lib file and the executable on the
evolutionary path,
DLLs are actually linked , .lib files are merely repositories for .obj files
and other .libs, just
packaged into a more convenient medium. Symbols in DLLs have to be
partially resolved,
that is to say if you call foo() it better be in the DLL or in another DLL
which the first
DLL refers to.
..lib files are linked into the executable code. The code in the .lib file
"becomes" part of
the executable. They are really just collections of .obj's
When you create a DLL, a .lib is also created. This is actually a "proxy"
which I will explain.
The DLL's .lib file will contain stubs or dummies for each of the functions
you export from the dll.
The .lib is linked into your executable as a place holder to call functions
in the DLL.
When you make a call to a function foobar(), the .lib stub foobar() will
actually execute the
function in the dll for you. This is all taken care of under the hood for
you when you use DLLs.
The advantages of DLLs are:
1. you can update the DLL without relinking the executable or
redistribution the executable.
( provided you don't add new functions or changes interfaces )
2. One DLL can be shared amongst a number of different executables so you
save on disk storage.
In reality, there are normally several copies of a DLL because
executables often require an
exact version of a dll to work correctly.
3. Since DLLs can be loaded on-demand, the start up time of the exectuable,
its memory footprint, etc
can be minimized to the essential functionality. Many of microsoft's
products make heavy use of
this feature through another technology called COM, which provides a
streamlined means to
execute functions in a dynamically loaded DLL.
Disadvantages:
1. DLL HELL - you have multiple versions of DLL which are all incompatible
with each other.
2. DLL code may be slightly slower in execution speed because of the code
has be to
relocatable at run-time and certain optimizations cannot be performed.
3. You have to ship DLLS along with the executable, so its a bit more
complex in deployment.
You also have to be sure your executable is picking up the correct
versions of DLLs on the
system.
4. There are some arcane rules for exporting functions from a DLL, just
adding the code is
not enough. However, these rules are fairly mechanical, and can be
mastered after a few
encounters.
Hope that helps.
dave