[GRASS5] Re: [GRASS-CVS] glynn: grass51 configure,1.73,1.74 configure.in,1.63,1.64

Glynn Clements glynn at gclements.plus.com
Fri Dec 10 11:13:57 EST 2004


Huidae Cho wrote:

> I found that AC_CHECK_FUNC(gdal) doesn't work in cygwin.
> 
> gcc -o conftest -g -O2    -Wl,--export-dynamic \
> 	-L/usr/local/lib -L/usr/X11R6/lib -L/usr/local/lib -lgdal conftest.c
> 
> doesn't compile, but the following is fine when I changed AC_CHECK_FUNC to
> AC_CHECK_LIB:
> 
> gcc -o conftest -g -O2    -Wl,--export-dynamic \
> 	-L/usr/local/lib -L/usr/X11R6/lib conftest.c -L/usr/local/lib -lgdal
> 
> If there is no reason to keep AC_CHECK_FUNC, I think AC_CHECK_LIB would be
> better.

We don't have the name of a specific library, only a list of switches.

> ---<diff>---
> -ac_save_ldflags="$LDFLAGS"
> -LDFLAGS="$LDFLAGS $GDAL_LIBS"
> -AC_CHECK_FUNC(GDALOpen,[],[
> -LDFLAGS="$LDFLAGS $GDAL_DEP_LIBS"
> -AC_CHECK_FUNC(GDALOpen,[GDAL_LIBS="$GDAL_LIBS $GDAL_DEP_LIBS"],[
> +AC_CHECK_LIB(gdal,GDALOpen,,[
> +AC_CHECK_LIB(gdal,GDALOpen,GDAL_LIBS="$GDAL_LIBS $GDAL_DEP_LIBS",[
>      AC_MSG_ERROR([*** Unable to locate GDAL library.])
>  ])
>  ])
> -LDFLAGS=${ac_save_ldflags}
> ------------

According to the autoconf Info file:

 -- Variable: LDFLAGS
     Stripping (`-s') and any other miscellaneous options for the
     linker.  If it is not set in the environment when `configure' runs,
     the default value is empty.  `configure' uses this variable when
     linking programs to test for C features.

 -- Variable: LIBS
     `-l' and `-L' options to pass to the linker.

So, we should probably be using LIBS rather than LDFLAGS. I suspect
that $LIBS will go at the end of the link command, which is required
for static libraries to work.

Using AC_CHECK_LIB(gdal,...) is wrong; we should be using whatever
"gdal-config --libs" says, in case the library isn't called "gdal"
(the GDAL bridge code suggests that the name might include the
version, requiring e.g. -lgdal11 or -lgdal.1.1).

> This is another issue. My autoconf doesn't include the following code snippet
> in configure. Do we need this? If so, for what?

[snip]

None of the configure scripts which I have here include that code. I
suspect that code is due to someone recently committing a version
generated using a later version of autoconf (all of the versions I
have here used 2.13; most modern systems have a newer version).

As the old versions have worked fine for years, I don't think that we
need that code.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list