autoconf: Running the Linker

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