[Top][All Lists]

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

Re: Having trouble using AC_CHECK_LIB

From: Gavin Smith
Subject: Re: Having trouble using AC_CHECK_LIB
Date: Mon, 2 Mar 2015 09:38:01 +0000

On 2 March 2015 at 06:10, Harlan Stenn <address@hidden> wrote:
>> I'm stuck at one part. Project: Starfighter requires SDL_Image and
>> SDL_Mixer from SDL2 in order to build, so I'm trying to check for them
>> by using AC_CHECK_LIB with functions defined by SDL_Image and
>> SDL_Mixer. These are my checks (you can see the attached file for the
>> full
>>     AC_CHECK_LIB([SDL2], [SDL_Init], [], [echo "Error: SDL2 not
>> found." ; exit 1])
>>     AC_CHECK_LIB([SDL2], [IMG_Load], [], [echo "Error: SDL_Image not
>> found." ; exit 1])
>>     AC_CHECK_LIB([SDL2], [Mix_LoadWAV], [], [echo "Error: SDL_Mixer
>> not found." ; exit 1])
> AC_CHECK_LIB is OK, and AC_SEARCH_LIBS might be better.
> Don't use echo like that.
> Do the AC_CHECK_LIB and after it's done check ac_cv_lib_SDL_Init or
> other values, and if those are missing call AC_MSG_ERROR to note your
> error condition and exit.
> Or if you use AC_SEARCH_LIBS use ac_cv_search_SDL_Init (or whatever) and
> check that way.

I'd argue this is a failing of the autoconf manual. It lacks a simple
example of checking the "ac_cv_lib_LIBRARY_FUNCTION" after the use of
AC_CHECK_LIB. Even if the writer of understands they can
check this variable, it's not easy to work out how to check the
variable in portable shell script with the help of autoconf macros.

 It's not obvious from the autoconf manual what a "cache variable"
should be used for in any case. It gives the impression that they are
mainly used for speeding up the run:
This leads a reader to think they can be ignored up until the point
when the configure is taking too long to run. It's not obvious that
they are shell variables accessible in the script, and
that checking their values is needed/encouraged.

The ordering of the information in
makes it difficult to understand what is done with the results of
tests. Section 7.1 "Defining C Preprocessor Symbols" refers to "cache
variables", but if you were reading this chapter in order, you
wouldn't learn about cache variables until section 7.4. (It also
refers to "output variables", which aren't explained until section

reply via email to

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