Installing a Library

Now that the library and an executable which links with it have been successfully built, they can be installed. For the sake of this example I will cp the objects to their destination, though libtool would be just as happy if I were to use install with the long, requisite list of parameters.

It is important to install the library to the -rpath destination which was specified when it was linked earlier, or at least that it be visible from that location when the runtime loader searches for it. This rule is not enforced by libtool, since it is often desirable to install libraries to a staging [1] area. Of course, the package must ultimately install the library to the specified -rpath destination for it to work correctly, like this:
     $ libtool cp libtrim.la /usr/local/lib
     cp .libs/libtrim.sl.0.0 /usr/local/lib/libtrim.sl.0.0
     (cd /usr/local/lib && rm -f libtrim.sl.0 && \
     ln -s libtrim.sl.0.0 libtrim.sl.0)
     (cd /usr/local/lib && rm -f libtrim.sl && \
     ln -s libtrim.sl.0.0 libtrim.sl)
     chmod 555 /usr/local/lib/libtrim.sl.0.0
     cp .libs/libtrim.lai /usr/local/lib/libtrim.la
     cp .libs/libtrim.a /usr/local/lib/libtrim.a
     ranlib /usr/local/lib/libtrim.a
     chmod 644 /usr/local/lib/libtrim.a     ----------------------------------------------------------------------
     Libraries have been installed in:
        /usr/local/lib
     
     If you ever happen to want to link against installed libraries
     in a given directory, LIBDIR, you must either use libtool, and
     specify the full pathname of the library, or use -LLIBDIR
     flag during linking and do at least one of the following:
        - add LIBDIR to the SHLIB_PATH environment variable
          during execution
        - use the -Wl,+b -Wl,LIBDIR linker flag
     
     See any operating system documentation about shared libraries for
     more information, such as the ld(1) and ld.so(8) manual pages.
     ----------------------------------------------------------------------

Notes

[1]

When making a binary package from a virtual root directory for example.