Search code examples
autoconf

Library resolution with 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...


Solution

  • You need to manually set CFLAGS, CXXFLAGS and LDFLAGS if you want gcc/g++ to look in non-standard locations.

    So, before calling AC_CHECK_LIB(), do something like

    CFLAGS="$CFLAGS -I/opt/local/include"
    CXXFLAGS="$CXXFLAGS -I/opt/local/include"
    LDFLAGS="$LDFLAGS -L/opt/local/lib"
    

    You don't need CXXFLAGS if you're only using gcc throughout your configure script.