Seth M. Landsman wrote:

>       Okay, this seems like as good a place as any to flaunt my
> ignorance.  So most of my unix programming experience is in minor kernel
> hacking and lots of self contained project.  Because of this background, I
> don't have a clue of what might be necessary to write a decent, usable
> shared library.  Can someone throw a reference my way?

Are you asking how to compile one, or what to put in it?

Compiling it just involves:

a) using the `-PIC' flag when compiling the object files, and

b) linking the object files together into a shared library, e.g.

gcc -shared -o libfoo.so.1.2 -Wl,-soname,libfoo.so.1 file1.o file2.o file3.o

The `-Wl,-soname,libfoo.so.1' passes `-soname libfoo.so.1' to the
linker, which sets the library's `soname' to `libfoo.so.1'.

When you link against a shared library, the linker records the soname
of each shared library in the executable. This is the information
which ld-linux.so uses to determine which shared libraries are
required at run time. The convention is for the soname to consist of
the library name and the major version number.

When you run the executable, ld-linux.so looks for each library using
the soname as the filename. When it finds a matching library, it
checks the library's soname against the one in the executable, and
only uses the library if the sonames match. This prevents you from
inadvertently using an incompatible version of a shared library
(provided that the library's author increments the major version
number whenever an incompatible change is made).

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to