autoconf: Libraries
1
1 5.4 Library Files
1 =================
1
1 The following macros check for the presence of certain C, C++, Fortran,
1 or Go library archive files.
1
1 -- Macro: AC_CHECK_LIB (LIBRARY, FUNCTION, [ACTION-IF-FOUND],
1 [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
1 Test whether the library LIBRARY is available by trying to link a
1 test program that calls function FUNCTION with the library.
1 FUNCTION should be a function provided by the library. Use the
1 base name of the library; e.g., to check for `-lmp', use `mp' as
1 the LIBRARY argument.
1
1 ACTION-IF-FOUND is a list of shell commands to run if the link
1 with the library succeeds; ACTION-IF-NOT-FOUND is a list of shell
1 commands to run if the link fails. If ACTION-IF-FOUND is not
1 specified, the default action prepends `-lLIBRARY' to `LIBS' and
1 defines `HAVE_LIBLIBRARY' (in all capitals). This macro is
1 intended to support building `LIBS' in a right-to-left
1 (least-dependent to most-dependent) fashion such that library
1 dependencies are satisfied as a natural side effect of consecutive
1 tests. Linkers are sensitive to library ordering so the order in
1 which `LIBS' is generated is important to reliable detection of
1 libraries.
1
1 If linking with LIBRARY results in unresolved symbols that would
1 be resolved by linking with additional libraries, give those
1 libraries as the OTHER-LIBRARIES argument, separated by spaces:
1 e.g., `-lXt -lX11'. Otherwise, this macro may fail to detect that
1 LIBRARY is present, because linking the test program can fail with
1 unresolved symbols. The OTHER-LIBRARIES argument should be
1 limited to cases where it is desirable to test for one library in
1 the presence of another that is not already in `LIBS'.
1
1 `AC_CHECK_LIB' requires some care in usage, and should be avoided
1 in some common cases. Many standard functions like `gethostbyname'
1 appear in the standard C library on some hosts, and in special
1 libraries like `nsl' on other hosts. On some hosts the special
1 libraries contain variant implementations that you may not want to
1 use. These days it is normally better to use
1 `AC_SEARCH_LIBS([gethostbyname], [nsl])' instead of
1 `AC_CHECK_LIB([nsl], [gethostbyname])'.
1
1 The result of this test is cached in the
1 `ac_cv_lib_LIBRARY_FUNCTION' variable.
1
1 -- Macro: AC_SEARCH_LIBS (FUNCTION, SEARCH-LIBS, [ACTION-IF-FOUND],
1 [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
1 Search for a library defining FUNCTION if it's not already
1 available. This equates to calling
1 `AC_LINK_IFELSE([AC_LANG_CALL([], [FUNCTION])])' first with no
1 libraries, then for each library listed in SEARCH-LIBS.
1
1 Prepend `-lLIBRARY' to `LIBS' for the first library found to
1 contain FUNCTION, and run ACTION-IF-FOUND. If the function is not
1 found, run ACTION-IF-NOT-FOUND.
1
1 If linking with LIBRARY results in unresolved symbols that would
1 be resolved by linking with additional libraries, give those
1 libraries as the OTHER-LIBRARIES argument, separated by spaces:
1 e.g., `-lXt -lX11'. Otherwise, this macro fails to detect that
1 FUNCTION is present, because linking the test program always fails
1 with unresolved symbols.
1
1 The result of this test is cached in the `ac_cv_search_FUNCTION'
1 variable as `none required' if FUNCTION is already available, as
1 `no' if no library containing FUNCTION was found, otherwise as the
1 `-lLIBRARY' option that needs to be prepended to `LIBS'.
1