This creates a SharedLibrary file libfoo.so.1.0.1, with shared object name ("soname") libfoo.so, dependent on libquux. To make libfoo usable, you need to put it someplace ldconfig(8) will find it, and SymLink it to libfoo.so.1 and libfoo.so.

So long as you don't change the call signature of one of the functions (or what they do, in a way that would break programs), you can just bump the minor version of the library and programs using the SharedLibrary will just work. If you do change call signatures on existing functions or change their semantics, bump the version, try to recompile the programs, and check that they work correctly once they pass. Another way to make it usable is to put it in a directory refered to in your LD_LIBRARY_PATHEnvironmentVariable.

You may wish to use -Wl,-O1 when linking too, it will optimise the hashtables used for symbol lookup making the startup time faster.

Creating static shared libraries

In some cases you may not want your shared library to have any extra dependencies. In such a case you want your shared library to have its dependencies statically linked in. Even a simple shared library will have a couple of dependences:

libtool(1) is a package designed to assist with the creation of shared libraries. See the libtool(1) node for more information (eventually) about this program

One of the advantages of libtool is that it will use the correct linker options on different platforms, instead of you having to learn them all and putting them in your MakeFile/configure script. (For example GCC uses </tt>-shared</tt>, -fPIC, -soname for certain options, Solaris's CC uses -G, -KPIC, and -h respectively for those same options).

If you have a .c file you wish to include in a library with libtool, you need to make a .lo file for it:

One nice feature of libtool is that you can specify other shared libraries that this one will depend upon (in the LD_LIBSEnvironmentVariable above), and this will be included in the linker script -- any package linking against libtrace in the above example will automatically link against libpcap and libz as well.

Please note that any user can change the contents of pages on this site,
and therefore the Waikato Linux Users Group can offer no assurances that
the information is correct, and the information on this site is not
necessarily the opinion of the Waikato Linux Users Group, or any of its
members. If you have any complaints about the contents of this page,
please do not hesitate to contact the Waikato Linux Users Group, or, click
the Edit button!

Unless otherwise noted, all pages on this site are licensed under the
WlugWikiLicense.