You can 'link' an 'so' or an 'a' just as you would
a 'o' (object file). See the GCC docs for details.
An archive (.a) is merely a collection of '.o'
files contained within one file - the '.a' file.
The linker will extract copies of the required '.o'
files from within the '.a' file and link them into
your application (this is called 'static linking').
A Shared Object file (.so) also contains many
'.o' files within one file - the '.so' file. The
difference is in the internal format of the '.so' file
-AND- the way the linker handles these '.o'
files at link time. The linker inserts a REFERENCE
into you compiled program for each '.o' file found
in '.so' files. At runtime (when you execute
your program) the system RESOLVES all
of the REFERENCES in your program by
finding the '.so' files on disk and loading the
appropriate '.o' files from within them as part
of your program.
The choice between using 'libsomething.so' and
'libsomething.a' depends on several factors.
- linking with '.so' files produces smaller programs.
IF you plan to distribute your program to other
machines -and- you are sure that the other machines
have, or can get, the '.so' files you used at link-time,
then this is the way to go. Most of Linux is done this
way - as the core libs are in '.so' format and are
available on all machines.
- linking with '.a' files produces bigger programs, but
your program is 'self contained' and you do not
have to concern yourself with the availability of any
'.so' files when you run your program on another
machine. This approach is usually used when your
program requires some libs that are either custom
or hard to find.