[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using autoconf-lib-link outside gettext

From: Bruno Haible
Subject: Re: Using autoconf-lib-link outside gettext
Date: Fri, 20 May 2005 11:54:35 +0200
User-agent: KMail/1.5

Hrvoje Niksic wrote:
> I understand that the `autoconf-lib-link' subdirectory of the gettext
> distribution contains the infrastructure needed to use
> AC_LIB_LINKFLAGS in a separate program.  But there seem to be no
> instructions on how to integrate this directory with an existing
> program that uses Autoconf.

This is correct. Here's some documentation.
* Overview

AC_LIB_LINKFLAGS is an autoconf macro that searches for a library and
makes the found location available to the compilation process and to further
autoconf tests.

AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
the libraries corresponding to explicit and implicit dependencies.
Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
augments the CPPFLAGS variable.

The complexities that AC_LIB_LINKFLAGS deals with are the following:

  * The library is not necessarily already in the search path
    (CPPFLAGS for the include file search path, LDFLAGS for the library
    search path). The macro provide a --with-lib${name} option that can
    be used to indicate the location of the library and its include files.
    If not provided, the --prefix directory is searched as well.

  * The library is not necessarily already in the run time library search
    path. To avoid the need for setting an environment variable like
    LD_LIBRARY_PATH, the macro adds the appropriate run time search
    path options to the LIB${NAME} variable. This works on most systems.
    It can also be inhibited by the user who installs the package through
    the --disable-rpath option.

The macro also sets a variable LTLIB${NAME}, that should be used when
linking with libtool. Both LTLIB${NAME} and LIB${NAME} contain
essentially the same option, but where LIB${NAME} contains platform
dependent flags like '-Wl,-rpath', LTLIB${NAME} contains platform independent
flags like '-R'.)

* Maintainer instructions:

Suppose you want to use libz, the compression library.
1. In configure.ac you add the line


2. To your build-aux directory you add the file 'config.rpath' from

3. To you m4 directory (which stores autoconf macros used by your
package) you add the 3 files lib-link.m4, lib-ld.m4, lib-prefix.m4 from

4. In Makefile.in you add @LIBZ@ to the link command line of your
program. Or, if you are using automake, you add $(LIBZ) to the LDADD
variable that corresponds to your program.

* Dependencies

The dependencies list is a space separated list of library names that
lib${name} is known to depend upon. Example: If libfooy depends on libfoox,
and libfooz depends on libfoox and libfooy, you can write:

AC_LIB_LINKFLAGS([fooy], [foox])
AC_LIB_LINKFLAGS([fooz], [foox fooy])

Explicit dependencies are necessary if you cannot assume that a .la file,
created by libtool, is installed. If you can assume that libfooy.la is
installed by libtool (and has not been omitted by the package distributor!),
you can omit the explicit dependency and just write


This way, you don't need to know in advance which libraries the needed
library depends upon.

* Static vs. shared

The AC_LIB_LINKFLAGS macro finds the libraries regardless whether they
are installed as shared or static libraries.


> Is there any news on the option of integrating these macros into
> Autoconf?  In the 2002 thread at http://tinyurl.com/dyjfo the
> consensus seemed to be that AC_LIB_LINKFLAGS *should* be integrated.
> Akim Demaille agreed as well.  What went wrong?

In my opinion, autoconf currently has too few maintainers who have time
to spend on this.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]