[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4 Library Files

The following macros check for the presence of certain C, C++, or Fortran 77 library archive files.

Macro: AC_CHECK_LIB (library, function, [action-if-found], [action-if-not-found], [other-libraries])
Depending on the current language(see section 6.1 Language Choice), try to ensure that the C, C++, or Fortran 77 function function is available by checking whether a test program can be linked with the library library to get the function. library is the base name of the library; e.g., to check for `-lmp', use `mp' as the library argument.

action-if-found is a list of shell commands to run if the link with the library succeeds; action-if-not-found is a list of shell commands to run if the link fails. If action-if-found is not specified, the default action will prepend `-llibrary' to LIBS and define `HAVE_LIBlibrary' (in all capitals). This macro is intended to support building LIBS in a right-to-left (least-dependent to most-dependent) fashion such that library dependencies are satisfied as a natural side-effect of consecutive tests. Some linkers are very sensitive to library ordering so the order in which LIBS is generated is important to reliable detection of libraries.

If linking with library results in unresolved symbols that would be resolved by linking with additional libraries, give those libraries as the other-libraries argument, separated by spaces: e.g., `-lXt -lX11'. Otherwise, this macro will fail to detect that library is present, because linking the test program will always fail with unresolved symbols. The other-libraries argument should be limited to cases where it is desirable to test for one library in the presence of another that is not already in LIBS.

Macro: AC_SEARCH_LIBS (function, search-libs, [action-if-found], [action-if-not-found], [other-libraries])
Search for a library defining function if it's not already available. This equates to calling `AC_LINK_IFELSE([AC_LANG_CALL([], [function])])' first with no libraries, then for each library listed in search-libs.

Add `-llibrary' to LIBS for the first library found to contain function, and run action-if-found. If the function is not found, run action-if-not-found.

If linking with library results in unresolved symbols that would be resolved by linking with additional libraries, give those libraries as the other-libraries argument, separated by spaces: e.g., `-lXt -lX11'. Otherwise, this macro will fail to detect that function is present, because linking the test program will always fail with unresolved symbols.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Jeff Bailey on December, 24 2002 using texi2html