[Top][All Lists]

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

Integration of autoconf and pkg-config

From: Stefano Sabatini
Subject: Integration of autoconf and pkg-config
Date: Tue, 18 Dec 2007 14:40:31 +0100
User-agent: Mutt/1.5.16 (2007-06-11)

Hi all,

I'm trying to package an application which uses some libraries using
the pkg-config system to automatically setup the compilation and
linking flags (namely the ffmpeg libraries).

The pkg-config system is also useful because it lets you specify
easily some constraints checking the version of the library installed,
pkg-config --atleast-version=51.0.1 libavformat 

I'm using pkg-config to determine the extralibs required to compile
and link my application.

The only thing the user has to care about in this case is to have the
.pc (pkg-config) files in the right directory looked up by pkg-config,
which can be eventually customized setting the PKG_CONFIG_PATH
environment variable.

The drawback of the pkg-config approach is that it highly relies on
its own database of PC files, if the user mangles it (for example
manually removing some library/header file) then a pkg-config query
will report no problem but the application won't link/compile.

On the other hand the AC_CHECK_LIB and AC_CHECK_HEADERS looks in the
standard dirs for both libs and headers (eventually customized setting
the LD_FLAGS and CPPFLAGS dirs), so it verifies the actual presence
and usability of the various libraries/headers, but can't check for
example for the version of the libraries detected, which can be easily
be performed by pkg-config --modversion=X.Y.Z libfoo.

A possible solution could be to use both pkg-config to perform
version/presence queries and the autoconf macros to verify their
effective usability, but this turns out to be messy, since if the user
happens to have libraries/headers in some path specified by LD_FLAGS
and CPPFLAGS and she doesn't specify a corresponding PKG_CONFIG_PATH
then there will be a mismatch between the informations reported by the
autoconf macros.

For example: the user may customize the LD_FLAGS and CPPFLAGS so that
they point to some directory where she installed the required
libraries which are checked by the autoconf macros, when the .pc file
checked by pkg-config may refer to some already installed system libs.

A solution could be then to write a little test program to run during
configuration which uses the flags provided by pkg-config (I wonder if
there is already some macro which can do it in autoconf).

So my (very general) question is: which is the right approach to
integrate autoconf and pkg-config?

I hope to have expressed clearly the problem, sorry for the very
likely misunderstanding I'm eventually showing about

Many thanks in advance for any suggestion/idea.
Stefano Sabatini
Linux user number 337176 (see

reply via email to

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