Library resolution with autoconf

autoconf

I'm building my first autoconf managed package.

However I can't find any simple examples anywhere of how to specify a required library, and find that library where it might be in various different places.

I've currently got:

AC_CHECK_LIB(['event'], ['event_init'])

but:

  1. It doesn't find the version installed in /opt/local/lib
  2. It doesn't complain if the library isn't actually found
  3. I need to set the include path to /opt/local/include too

any help, or links to decent tutorials much appreciated…

Best Answer

autoconf script cannot guess the "optional" library locations, which may vary from one platform to another. So you can say

CPPFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib" ./configure

For AC_CHECK_LIB() you need to specify the fail condition explicitly in "action-if-false" argument:

dnl This is simply print "no" and continue:
AC_CHECK_LIB([m], [sqrt123])
dnl This will stop:
AC_CHECK_LIB([m], [sqrt123], [], [AC_MSG_ERROR([sqrt123 was not found in libm])])

Output:

checking for sqrt123 in -lm... no
checking for sqrt123 in -lm... no
configure: error: sqrt123 was not found in libm

AC_CHECK_LIB() does not fail by default on obvious reasons: one may check for several different libraries that provide similar functionality and choose one of them :)

Also have a look at this post for similar topic.

Related Topic