[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: library search test fails, please help

From: Allan Caffee
Subject: Re: library search test fails, please help
Date: Sun, 22 Feb 2009 13:39:20 -0500
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

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 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

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.
[override the default path to cpputils library])],
if test x"$withval" != x"no"

AC_MSG_CHECKING([for libcpputils.a])
if test -f "$cpputils_suggested_dir/lib/libcpputils.a"; then

Then you can just add @CPPUTILS_STATIC_LIB@ and @CPPUTILS_CFLAGS@ into
your (or 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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]