[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Building optional shared libraries
From: |
Steven G. Johnson |
Subject: |
Building optional shared libraries |
Date: |
Mon, 8 Oct 2001 19:55:51 -0400 (EDT) |
Bill Moseley wrote:
> I'm looking for an example use of autoconf to optionally use a shared
> library, and what to instructions to give when the library is
> installed in a non-standard location. I'm wondering if there's a
> standard approach.
I think that most of us agree that the "standard" approach is to tell the
user to use LDFLAGS and CPPFLAGS to tell configure to look in nonstandard
locations for libraries/headers, e.g.:
./configure LDFLAGS=-L/foo/lib CPPFLAGS=-I/foo/include
This is mentioned in the './configure --help' message. Steve Robbins
created a nice macro to make this a bit easier:
http://www.gnu.org/software/ac-archive/Installed_Packages/smr_with_build_path.html
(i.e. *don't* do --with-libfoo=<dir>)
For shared libraries, I would argue that the user should either:
1) Install it properly so that it can be shared by all programs...i.e.
tell the linker where to look (via LD_RUN_PATH or /etc/ld.so.conf).
2) Configure it with --disable-shared --enable-static and avoid shared
libraries entirely.
If the user is just compiling the library for use in your program, and
doesn't want to share it globally, I would recommend (2).
> Say the non-standard locations (which are the build directories) are
> $HOME/libxml2-2.4.5/include
> $HOME/libxml2-2.4.5/.libs
I would argue that linking to the build directory is wrong--the ".libs"
directory has a "." in front of it because it should *not* be
user-visible, and you should *not* depend on its contents. If you don't
want to install libxml in a system-wide location, you should configure it
with e.g. --prefix=$HOME/libxml and then do a proper 'make && make
install'.
I sympathize from personal experience: developing programs that require
the user to install other libraries is a pain. I believe, however, that
the correct solution (for people building from source) is to teach the
user how to properly install libraries on Unix...otherwise, you are just
compounding the problem.
Steven