On Sat, 21 Feb 2009, aaragon wrote: > I found working with autoconf sometimes very frustrating. Let's see if we can't change that. :) >This is an > example. I want to check for a particular static library that I created. > Thus, I put the following in the configure.ac file > > AC_CHECK_LIB([cpputils], [flip],,[AC_MSG_ERROR(library cpputils not > found)],,) > > The result for this test is (in config.log): > > configure:15746: checking for flip in -lcpputils > configure:15781: g++-mp-4.3 -g -O3 -o conftest -g -O2 > -I/Users/aaragon/Lib/include -L/Users/aaragon/Lib/lib conftest.cpp > -lcpputils >&5 > Undefined symbols: > "_flip", referenced from: > _main in ccZZadrT.o > ld: symbol(s) not found > collect2: ld returned 1 exit status > [...] > So can someone tell me why is this happening? The result of the test doesn't > make any sense. Thanks for the help, AC_CHECK_LIB (AFAIK) is not intended to handle static libraries. The reason for this is that compilers handle static libraries quite differently than shared object libraries. Compilers treat static libraries as a single big object file to be included along with all the others. For example to compile the test program you would use something like: g++-mp-4.3 -o conftest -g -O2 -I/Users/aaragon/Lib/include /Users/aaragon/Lib/lib/cpputils.a conftest.cpp I don't know of a way that's built into Autoconf to handle static libs this way. The way I usually handle it is with something like this: ## Provide commandline flags to allow users to override the default path ## to this static library. AC_ARG_WITH([cpputils], [AS_HELP_STRING([--with-cpputils=<DIR>], [override the default path to cpputils library])], [ if test x"$withval" != x"no" cpputils_suggested_dir=$withval; fi ],[]) AC_MSG_CHECKING([for libcpputils.a]) if test -f "$cpputils_suggested_dir/lib/libcpputils.a"; then CPPUTILS_STATIC_LIB="$cpputils_suggested_dir/lib/libcpputils.a" CPPUTILS_CFLAGS="-I$cpputils_suggested_dir/include" else CPPUTILS_STATIC_LIB="/Users/aarogon/Lib/lib/cpputils.a" CPPUTILS_CFLAGS="-I/Users/aarogon/Lib/include" fi Then you can just add @CPPUTILS_STATIC_LIB@ and @CPPUTILS_CFLAGS@ into your Makefile.in (or Makefile.am if you use Automake). Hope that helps! Aside to the developers: This seems to be a recurring issue on this list. We should really document this limitation of AC_CHECK_LIB and (maybe) provide a replacement macro. Thoughts? Cheers, Allan _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf