[Buildroot] AC_CHECK_LIB doesn't work for cross-compiling

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Fri Dec 26 14:31:07 UTC 2014


Dear Adam Jiang,

On Thu, 25 Dec 2014 22:03:02 +0900, Adam Jiang wrote:

> > 	AC_CHECK_LIB([fcgi], [FCGX_InitRequest], [LIBS="$LIBS -lfcgi],
> > 		[AC_MSG_WARN("unable to find the FCGX_InitRequest() function")],
> > 		[-lm])
> 
> Em...I can understand the issue now. However, would it be possible for 
> libfcgi to resolve its dependency somehow?

For dynamic linking, this should happen automatically, provided libfcgi
is properly linked against libm. But indeed, after a quick look, it
turns out that libfcgi uses frexp() but isn't linked against libm:

$ readelf -a libfcgi.so.0.0.0
[...]
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libnsl.so.0]
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libc.so.0]
 0x0000000e (SONAME)                     Library soname: [libfcgi.so.0]
[...]
   176: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND frexp

To me, this looks like a bug in libfcgi build system.

However, even if libfcgi is linked against libm, this will not solve
the case of static linking. In this case, the only proper solution
would be to extend libfcgi to install a .pc (pkg-config) file, and have
your package use PKG_CHECK_MODULES() instead of AC_CHECK_LIB().

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com



More information about the buildroot mailing list