[Top][All Lists]

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

Re: Library version thru autoconf ?

From: Tim Post
Subject: Re: Library version thru autoconf ?
Date: Mon, 16 Feb 2009 17:02:08 +0800

On Fri, 2009-02-13 at 11:09 -0700, Warren Young wrote:
> S├ębastien Le Roux wrote:
> > 
> > I wonder if there is a way (a macro ?) to obtain the version of a library.
> Maybe, but the Autoconf Way is to test for features, not versions.
> Take the simple case, only two supported versions of a library, old and 
> new.  You write a single autoconf test that tries to link a program 
> containing a routine only available in the new library.  AC_TRY_LINK  If 
> the new library differs only in the interface to the same set of 
> functions, you'd have to use AC_TRY_COMPILE instead, with an attempt to 
> call the newer interface.

>From help that I found some time ago on this list, I also recommend
AC_CHECK_MEMBER. Sometimes a change in a library adds something new to a
structure but does not change any exposed functions.

If you know that libfoo 3.1 has member 'bar' in struct 'foo' but 3.0
doesn't, you can give the user a more detailed description of what's
wrong in the error message (i.e. please upgrade foo to 3.1+).

Unfortunately, not all libraries define LIBNAME_VERSION, so trying to
get the output of:

#include <foo.h>

int main(void)
   fprintf(stderr, "%s", FOO_VERSION)

... where FOO is the name of whatever library you are examining isn't
going to work very reliably. Moreover, some actually do define the
version but not in major / minor formats, so hard to tell if you have
3.1 or 3.5. Finally, some just say FOO_VERSION, or FOO_MAJOR instead of

Its a little too much magic to put in any single macro :) You could
probably write one that worked 80% of the time .. but that's a 20%
chance that the build will break with linker errors that most won't


reply via email to

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