DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(autocf21.info.gz) Examining Libraries

Info Catalog (autocf21.info.gz) Examining Syntax (autocf21.info.gz) Writing Tests (autocf21.info.gz) Run Time
 
 5.3 Examining Libraries
 =======================
 
 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 `nm' or `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 `nm' and `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.
 
    A few systems have linkers that do not return a failure exit status
 when there are unresolved functions in the link.  This bug makes the
 configuration scripts produced by Autoconf unusable on those systems.
 However, some of them can be given options that make the exit status
 correct.  This is a problem that Autoconf does not currently handle
 automatically.  If users encounter this problem, they might be able to
 solve it by setting `LDFLAGS' in the environment to pass whatever
 options the linker needs (for example, `-Wl,-dn' on MIPS RISC/OS).
 
    `AC_TRY_LINK' is used to compile test programs to test for functions
 and global variables.  It is also used by `AC_CHECK_LIB' to check for
 libraries ( Libraries), by adding the library being checked for
 to `LIBS' temporarily and trying to link a small program.
 
  -- Macro: AC_TRY_LINK (INCLUDES, FUNCTION-BODY, [ACTION-IF-FOUND [,
           ACTION-IF-NOT-FOUND]])
      Depending on the current language ( Language Choice),
      create a test program to see whether a function whose body
      consists of FUNCTION-BODY can be compiled and linked.
 
      For C and C++, INCLUDES is any `#include' statements needed by the
      code in FUNCTION-BODY (INCLUDES will be ignored if the currently
      selected language is Fortran 77).  This macro also uses `CFLAGS'
      or `CXXFLAGS' if either C or C++ is the currently selected
      language, as well as `CPPFLAGS', when compiling.  If Fortran 77 is
      the currently selected language then `FFLAGS' will be used when
      compiling.  However, both `LDFLAGS' and `LIBS' will be used during
      linking in all cases.
 
      If the file compiles and links successfully, run shell commands
      ACTION-IF-FOUND, otherwise run ACTION-IF-NOT-FOUND.
 
  -- Macro: AC_TRY_LINK_FUNC (FUNCTION, [ACTION-IF-FOUND [,
           ACTION-IF-NOT-FOUND]])
      Depending on the current language ( Language Choice),
      create a test program to see whether a program whose body consists
      of a prototype of and a call to FUNCTION can be compiled and
      linked.
 
      If the file compiles and links successfully, run shell commands
      ACTION-IF-FOUND, otherwise run ACTION-IF-NOT-FOUND.
 
  -- Macro: AC_TRY_LINK_FUNC (FUNCTION, [ACTION-IF-FOUND [,
           ACTION-IF-NOT-FOUND]])
      Attempt to compile and link a small program that links with
      FUNCTION.  If the file compiles and links successfully, run shell
      commands ACTION-IF-FOUND, otherwise run ACTION-IF-NOT-FOUND.
 
  -- Macro: AC_COMPILE_CHECK (ECHO-TEXT, INCLUDES, FUNCTION-BODY,
           ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
      This is an obsolete version of `AC_TRY_LINK', with the addition
      that it prints `checking for ECHO-TEXT' to the standard output
      first, if ECHO-TEXT is non-empty.  Use `AC_MSG_CHECKING' and
      `AC_MSG_RESULT' instead to print messages ( Printing
      Messages).
 
Info Catalog (autocf21.info.gz) Examining Syntax (autocf21.info.gz) Writing Tests (autocf21.info.gz) Run Time
automatically generated byinfo2html