Opened 13 years ago

Closed 10 years ago

Last modified 10 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

Description

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

Change History (13)

comment:1 Changed 13 years ago by warmerdam

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 Changed 11 years ago by Kyle Shannon

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

comment:3 Changed 11 years ago by Ari Jolma

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

comment:4 Changed 11 years ago by Kyle Shannon

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

comment:5 Changed 10 years ago by Kyle Shannon

Cc: Kyle Shannon added

comment:6 Changed 10 years ago by etourigny

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 Changed 10 years ago by Even Rouault

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 Changed 10 years 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)...

comment:9 Changed 10 years ago by Even 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.

comment:10 Changed 10 years ago by etourigny

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 Changed 10 years ago by Kyle Shannon

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 Changed 10 years ago by etourigny

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

comment:13 Changed 10 years ago by Kyle Shannon

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.