To check for a library, a function, or a global variable, Autoconf
configure scripts try to compile and link a small program that
uses it. This is unlike Metaconfig, which by default uses
ar on the C library to try to figure out which functions are
available. Trying to link with the function is usually a more reliable
approach because it avoids dealing with the variations in the options
and output formats of
ar and in the location of the
standard libraries. It also allows configuring for cross-compilation or
checking a function’s runtime behavior if needed. On the other hand,
it can be slower than scanning the libraries once, but accuracy is more
important than speed.
AC_LINK_IFELSE is used to compile test programs to test for
functions and global variables. It is also used by
to check for libraries (see Checks for Libraries), by adding the
checked for to
LIBS temporarily and trying to link a small
Run the compiler (and compilation flags) and the linker of the current
language (see Language Choice) on the input, run the shell
commands action-if-true on success, action-if-false
otherwise. The input can be made by
friends. If needed, action-if-true can further access the
just-linked program file conftest$EXEEXT.
LIBS are used for linking, in addition to the
current compilation flags.
It is customary to report unexpected failures with
AC_MSG_FAILURE. This macro does not try to execute the program;
AC_RUN_IFELSE if you need to do that (see Runtime).
AC_LINK_IFELSE macro cannot be used for Erlang tests, since Erlang
programs are interpreted and do not require linking.