Next: , Previous: , Up: Using libtool   [Contents][Index]

3.5 Installing libraries

Installing libraries on a non-libtool system is quite straightforward… just copy them into place:4

burger$ su
Password: ********
burger# cp libhello.a /usr/local/lib/libhello.a

Oops, don’t forget the ranlib command:

burger# ranlib /usr/local/lib/libhello.a

Libtool installation is quite simple, as well. Just use the install or cp command that you normally would (see Install mode):

a23# libtool --mode=install cp /usr/local/lib/
cp /usr/local/lib/
cp .libs/libhello.a /usr/local/lib/libhello.a
ranlib /usr/local/lib/libhello.a

Note that the libtool library is also installed, to help libtool with uninstallation (see Uninstall mode) and linking (see Linking executables) and to help programs with dlopening (see Dlopened modules).

Here is the shared library example:

burger# libtool --mode=install install -c \
install -c .libs/ /usr/local/lib/
install -c /usr/local/lib/
install -c .libs/libhello.a /usr/local/lib/libhello.a
ranlib /usr/local/lib/libhello.a

It is safe to specify the -s (strip symbols) flag if you use a BSD-compatible install program when installing libraries. Libtool will either ignore the -s flag, or will run a program that will strip only debugging and compiler symbols from the library.

Once the libraries have been put in place, there may be some additional configuration that you need to do before using them. First, you must make sure that where the library is installed actually agrees with the -rpath flag you used to build it.

Then, running ‘libtool -n finish libdir’ can give you further hints on what to do (see Finish mode):

burger# libtool -n finish /usr/local/lib
PATH="$PATH:/sbin" ldconfig -m /usr/local/lib
Libraries have been installed in:

To link against installed libraries in a given directory, LIBDIR,
you must use the '-LLIBDIR' flag during linking.

 You will also need to do one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-RLIBDIR' linker flag

See any operating system documentation about shared libraries for
more information, such as the ld and manual pages.

After you have completed these steps, you can go on to begin using the installed libraries. You may also install any executables that depend on libraries you created.



Don’t strip static libraries though, or they will be unusable.

Next: , Previous: , Up: Using libtool   [Contents][Index]