I know that you can search for a specific function within a library using AC_SEARCH_LIBS
, but this only tells you whether or not a library is in the library path and satisfies certain conditions. Is there an easy way to get the path--or more specifically the prefix of the library that satisfied AC_SEARCH_LIBS
?
For example, say I wrote
AC_SEARCH_LIBS([dlopen],[dl],[],[])
this just lets me do something based on whether or not I find a library named dl containing dlopen, but it does not tell me where that library is on disk.
I need to do this because the build command for one of the programs I'm wrapping requires the prefix for the library, and not just a library name.
There is no standard way to do what you want except using pkg-config
. If the library you're looking for provides .pc
files, you can query for the libdir
variable of it to figure out where the file likely is (although there is no guarantee of it.)
PKG_CHECK_VAR([FOO_LIBDIR], [foo], [libdir])
AC_MSG_CHECKING([foo library path])
AS_IF([test "x$FOO_LIBDIR" = "x"], [
AC_MSG_FAILURE([Unable to identify foo lib path.])
])
You can find more information on PKG_CHECK_VAR
on my Autotools Mythbuster.
For system libraries and in general libraries there is no standard way to do so — mostly because cross-compiling mean you don't really know what that path will be when you actually run the software.