Ticket #2657 (closed defect: fixed)

Opened 3 years ago

Last modified 6 weeks ago

--with-netcdf=diretory does not really test netcdf

Reported by: ajolma Owned by: warmerdam
Priority: low Milestone:
Component: ConfigBuild Version: unspecified
Severity: minor Keywords: netcdf
Cc: kyle, pds

Description

If netcdf is attempted to be included specifying --with-netcdf=<directory> the library is not tested.

Change History

Changed 3 years ago by warmerdam

  • keywords netcdf added
  • priority changed from normal to low
  • severity changed from normal to minor

This is a fairly common behavior for configure and I don't consider it is necessarily a defect, though of course more careful checking is desirable.

Changed 18 months ago by kyle

Has this been updated? Is the code:

elif test "$with_netcdf" = "yes" -o "$with_netcdf" = "" ; then

  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nc_open in -lnetcdf" >&5
$as_echo_n "checking for nc_open in -lnetcdf... " >&6; }
if test "${ac_cv_lib_netcdf_nc_open+set}" = set; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lnetcdf  $LIBS"

sufficient for this check, or does more need to be added? I am not too familiar with the configure script

Changed 18 months ago by ajolma

Hm, maybe just adding the AC_CHECK_LIB macro in the last case (else...fi) would be enough. But as Frank comments, expecting a test in this case is probably expecting too much.

BTW, instead of trying to improve the autotools config, I'd probably invest more into looking at what could be done with cmake ( http://code.google.com/p/gdal-cmake/)

Changed 18 months ago by kyle

Sounds good, I am just stepping through and trying to find the status of the netCDF tickets.

Changed 7 weeks ago by kyle

  • cc kyle added

Changed 7 weeks ago by etourigny

  • cc pds added
  • status changed from new to closed
  • resolution set to fixed

fixed in trunk (r23648)

Fix is not perfect because it picks up any netcdf, not specifically the one specified in --with-netcdf. This seems to be a limitation of gcc/autoconf, unless I have missed something.

I have also added a test for --with-netcdf/lib directory to limit unnecessary additions to LIBS EXTRA_INCLUDES (as is done for other libs)

Pat, Kyle: please advise if this fix breaks something.

Changed 7 weeks ago by rouault

  • status changed from closed to reopened
  • resolution fixed deleted

I believe the AC_CHECK_LIB is not correct. If there's no netcdf lib in /usr/lib or /usr/local/lib, I'm pretty sure it would fail. You could try the following (untested !) :

AC_CHECK_LIB([netcdf], [nc_open], [NETCDF_SETTING=yes], [NETCDF_SETTING=no],-L$with_netcdf -L$with_netcdf/lib)

I'd like also remind you to proceed with caution at this point, now that we are past beta2...

Changed 7 weeks ago by etourigny

You are right, It does not work without a system netcdf, and your fix works. Do you know how I could *exclude* pre-installed libnetcdf? I tried temporarily setting LDFLAGS and LIBS, but it always picks up the one in /usr.

After fixing this I am done poking around for some time (except for new bugs)...

Changed 7 weeks ago by rouault

No, unfortunately I don't think there's a way to exclude pre-installed libs in system directories. This is a common issue. Sometimes it's due to another packages that adds explicitely -L/usr/lib in $LIBS. If you edit GDALmake.opt at hand and remove all occurences of -L/usr/lib in LIBS, then you have a chance to get the linking with the lib in the custom directory. Then you need of course LD_LIBRARY_PATH to point to the right directory.

Changed 7 weeks ago by etourigny

  • status changed from reopened to closed
  • resolution set to fixed

That's what I thought, thanks. Ideally configure should check for working libnetcdf in the --with-netcdf directory, but current implementation is safe enough. When user installs netcdf in a custom directory (and keeps system installed version), then he/she should be careful enough to make sure the lib exists within --with-netcdf. Besides, a problem will occur at link and/or compile time if not.

Fixed in r23649.

Changed 6 weeks ago by kyle

Etienne, Seems to work on fedora, even when --with-netcdf is not defined. The configure script picks up libnetcdf in /usr/local/[lib bin include] and gives me netcdf4 support.

Changed 6 weeks ago by etourigny

thanks Kyle, so you confirm it works also with --with-netcdf=/usr/local ?

Changed 6 weeks ago by kyle

Yes, I have netcdf installed in /usr from yum, /usr/local from my build of 4.1.1, and in a non-system folder from 4.1.1. With out specifying --with-netcdf=, it picks up the /usr libs, with the --with-netcdf flag, but no argument is uses /usr, and uses the correct builds if I specify --with-netcdf=/path/to/any/netcdf/build.

kss

Note: See TracTickets for help on using tickets.