Unix Programming - AC_CHECK_LIB problem

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2004 > AC_CHECK_LIB problem





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author AC_CHECK_LIB problem
Uwe Mayer

2004-11-26, 7:50 am

Hi,

I have a configure.in script which uses AC_CHECK_LIB to search for a 3rd
party static archive (.a) which is located at a custom location.
The autoconf docs do not state what paths AC_CHECK_LIBS searches for, but
some ac-linker-test says it uses current LDFLAGS and LIBS environment
variables.

Does anyone know more on AC_CHECK_LIB, i.e. where it looks or wether it
finds static archives at all?

Also I found code like:
AC_CHECK_LIB(m, main, , AC_MSG_ERROR([...]))

which checks for libmath. However nm does not find a symbol "main" in
libmath.so and libraries usually don't have a main routine, don't they?

Thanks
Ciao
Uwe

Måns Rullgård

2004-11-26, 7:50 am

Uwe Mayer <merkosh@hadiko.de> writes:

> Hi,
>
> I have a configure.in script which uses AC_CHECK_LIB to search for a 3rd
> party static archive (.a) which is located at a custom location.
> The autoconf docs do not state what paths AC_CHECK_LIBS searches for, but
> some ac-linker-test says it uses current LDFLAGS and LIBS environment
> variables.
>
> Does anyone know more on AC_CHECK_LIB, i.e. where it looks or wether it
> finds static archives at all?


AC_CHECK_LIB(lib, func) creates a simple test program, something like

int main(){
func();
return 0;
}

and tries to compile it with "$CC $CFLAGS $LDFLAGS -llib conftest.c"
(or something very similar). If the compile succeeds, the conclusion
is that the library exists in one of the places searched by the
linker.

> Also I found code like:
> AC_CHECK_LIB(m, main, , AC_MSG_ERROR([...]))
>
> which checks for libmath. However nm does not find a symbol "main" in
> libmath.so and libraries usually don't have a main routine, don't they?


This is probably used to check for the presence of a library, without
testing for any particular function in the library. main() will be
defined in the test program, so the link will succeed. IMHO, it is
preferred to test for (one of) the function(s) you actually use in
your program.

--
Måns Rullgård
mru@inprovide.com
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com