Opened 15 years ago

Closed 12 years ago

Last modified 12 years ago

#2657 closed defect (fixed)

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

Reported by: Ari Jolma Owned by: warmerdam
Priority: low Milestone:
Component: ConfigBuild Version: unspecified
Severity: minor Keywords: netcdf
Cc: Kyle Shannon, pds


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

Change History (13)

comment:1 by warmerdam, 15 years ago

Keywords: netcdf added
Priority: normallow
Severity: normalminor

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.

comment:2 by Kyle Shannon, 14 years ago

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
LIBS="-lnetcdf  $LIBS"

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

comment:3 by Ari Jolma, 14 years ago

Hm, maybe just adding the AC_CHECK_LIB macro in the last case ( 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 (

comment:4 by Kyle Shannon, 14 years ago

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

comment:5 by Kyle Shannon, 12 years ago

Cc: Kyle Shannon added

comment:6 by etourigny, 12 years ago

Cc: pds added
Resolution: fixed
Status: newclosed

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.

comment:7 by Even Rouault, 12 years ago

Resolution: fixed
Status: closedreopened

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

comment:8 by etourigny, 12 years ago

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

comment:9 by Even Rouault, 12 years ago

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.

comment:10 by etourigny, 12 years ago

Resolution: fixed
Status: reopenedclosed

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.

comment:11 by Kyle Shannon, 12 years ago

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.

comment:12 by etourigny, 12 years ago

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

comment:13 by Kyle Shannon, 12 years ago

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.


Note: See TracTickets for help on using tickets.