01-27-04 02:35 PM
Nick <nbdy9@hotmail.com.nospam> wrote:quote:
> What's different between Library (.a) and Shared object (.o)?
.o files (typically) are object files, i.e. the output of the compiler.
Usually several object files are linked together to make an executable.
.a files are static libraries. They aren't much more than a collection
(an "archive", that's where the 'a' comes from) of object files. They
can get linked together with one or more object file to make the final
program.
.so files are shared libraries. Basically, they also consist of object
files. But in contrast to static libraries, that get linked permanently
to an executable (become part of the executable after linking), they
only get added to the copy of executable in memory when it's run. The
executable contains just some information about which shared libraries
it needs to be run but not the whole code.
This can have several advantages. First of all, the executables are
smaller, you don't have to store the content of a static library
together with the executable. And since a libraries tend to get to
linked to a lot of programs you don't need to store maybe hundreds
of copies of the basically the same code (one for each program
linked against the static library) but only a single copy. Second,
since these shared libraries aren't integrated into the executable
you can install a new, improved version of a library and all already
existing executables using that library automatically get the new
version without the need to recompile all of them (as it would be
the case with static libraries). Finally, programs can also load
shared libraries while they are already runnig, allowing you to
create plug-ins that only get loaded on demand (and can be easily
be replaced without modifications to the program using them).
Regards, Jens
--
\ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de
\__________________________ http://www.physik.fu-berlin.de/~toerring
[ Post a follow-up to this message ]
|