I am hav开发者_JS百科ing a problem with a configure script verifying the presence of some basic functions,
AC_CHECK_FUNCS([floor gettimeofday memset pow sqrt sin exp])
Under certain criteria, the results are expected (checking for x... yes
). Otherwise the math functions above are claimed to be not defined. The difference is a call to verify some lapack routines first. These are checked by, AC_CHECK_LIB([lapack],[dsyev_],...
. If these checks are not done first, then the above math functions fail to check (final compilation works).
I've reduced the configure script to the following that recreates the issue,
AC_INIT([TEST], [0.0], [none@none.com])
#AC_CHECK_LIB([lapack],[dsyev_], , AC_MSG_FAILURE([Missing lapack]))
AC_CHECK_FUNCS([floor gettimeofday memset pow sqrt sin exp])
Uncommenting the second line results in proper visual results. I imagine that the math library isn't included or checked for some reason. In fact, AC_CHECK_LIB([m],[exp])
works fine.
What's the cause of this, and what is the proper way to use this directive? What kind of x-platform considerations should I observe?
The math functions are in the math library, so if you want them, you need to pull the math library into the link arguments that configure
uses. AC_CHECK_LIB([m],[exp])
is one way to do that. The reason that AC_CHECK_LIB([lapack],...)
also has that effect is that it quite probably pulls in -lm
itself (not knowing the library, but I read it's for linear algebra).
I suggest that you avoid AC_CHECK_LIB
and instead use AC_SEARCH_LIBS
for functions that are potentially not in the standard C library. So
AC_SEARCH_LIBS(exp, m)
AC_SEARCH_LIBS(dsyev_, lapack)
(But using AC_CHECK_LIB
is not actually wrong.)
精彩评论