[plug] Problem with Tekram scsi driver

Richard Sharpe sharpe at ns.aus.com
Fri Jun 15 12:33:07 WST 2001


At 11:17 AM 6/15/01 +0800, Simon Scott wrote:
>	While Im in learning mode, can someone give a short description of
>what the difference between .so and .a libraries are, anything special you
>need to do in C to 'make a dynamic library', and maybe how it all relates
>back to ld and ldconfig?

Hmmm, you ask the hard questions.

.a libraries are archive libraries, and are non-shared. When you link a
program with .a libraries, you bundle your code together with the library
code into one object that is self contained and will run.  When you run it,
it does not need anything more than the kernel itself (for system calls).

.so libraries, OTOH, are shared libraries. When you link with them, ld
builds references to the required symbols and the SO name required into the
final object that is built. When you run such a program, the run-time
loader must find the shared library and do a final run-time link. If the
shared library is already in memory, that is great, but if not, it must
load the appropriate parts. It also relocates all references so they point
to the routines in the .so (as it gets or got loaded). It is much more
complex. 

The differences then are:

  .a libraries generate self-contained executables that are more likely to 
  run on any system. However, they take up more disk space and more memory
  if you run lots of programs linked against the same .a file.

  .so libraries result in an executable that is dependendent on that .so 
  or one that is very similar (has not changed the API significantly, which
  means that has not changed the number of parameters on entry points used
  by the program linked against it). They are also slightly slower, but they 
  consume much less space on disk and in memory when multiple users of the
  shared library are loaded.

As to creating them, you generally have to generate PIC code, and there are
two flags for this, -fpic or -fPIC. Then you have to link them correctly as
well, and if you are versioning your library, have to provide the correct
SONAME etc.

Check a Makefile or .configure script for a moderately complex package that
you have to hand. Note also, that many UNIX systems do it differently. This
has been a bug-bear for me with my libsmbclient stuff in Samba. I can't
wait for the day when Linux rulz!


Regards
-------
Richard Sharpe, sharpe at ns.aus.com
Samba (Team member, www.samba.org), Ethereal (Team member, www.ethereal.com)
Contributing author, SAMS Teach Yourself Samba in 24 Hours
Author, Special Edition, Using Samba





More information about the plug mailing list