How do I use the Autoconf AC_SEARCH_LIBS macro in configure.ac in order to search for a static library when that library itself depends on other libraries?
Consider this example.
I am writing a set of high-level wrapping functions for the plotting library PLplot and putting my object files into a static library, libpsm.a, that gets installed by Automake into /usr/local/lib. The PLplot objects it depdends on are not in the library. Next, I have another program which I intend to use my library directly, and the PLplot library indirectly. In the configure.ac for that program I have this. The sm_device
function is one that is in my library.
AC_SEARCH_LIBS([sm_device],[psm],[],[
AC_MSG_ERROR([unable to find the sm_device function])
])
The problem I am experiencing is that this test fails because the AC_SEARCH_LIBS
macro tries to compile a small test program that links to the search library, libpsm.a
and call the function sm_device
, but that will fail because the test program does not also link to the PLplot libraries that it indirectly depends on.
The 5th argument to AC_SEARCH_LIBS is for listing the dependent libraries:
AC_SEARCH_LIBS (function, search-libs, [action-if-found],
[action-if-not-found], [other-libraries])
The other-libraries argument should be a space separated list of flags that will be passed to the linker during tests: eg -lm -lfoo -lbar
See http://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Libraries.html#Libraries