Opened 15 years ago

Closed 12 years ago

#3154 closed defect (wontfix)

Configure snippet is not truly able to manage both netcdf3 and netcdf4

Reported by: frankie Owned by: etourigny
Priority: normal Milestone:
Component: ConfigBuild Version: unspecified
Severity: normal Keywords: netcdf
Cc: warmerdam, antonio

Description (last modified by warmerdam)

When testing nc_open it does not consider that netcdf4 can be built with --enable-netcdf-4. In this case netcdf requires linking HDF5 and libz. Netcdf now offers a pkg-config snippet to manage properly linking. On sid it returns currently:

-L/usr -lnetcdf -lhdf5_hl -lhdf5 -lz  

There are different ways to support both netcdf3/traditional builds or the new one. It's up to you decide if splitting --with-netcdf3/4 is appropriate or having a try with pkg-config would be a better option.

Change History (6)

comment:1 by warmerdam, 15 years ago

Cc: warmerdam added
Description: modified (diff)
Keywords: netcdf added
Owner: changed from warmerdam to chaitanya

Chaitanya, could you look into this as time permits?

If older versions of the netcdf3 package does not have pkg-config, we may still need to support mechanisms for the user to override.

comment:2 by frankie, 15 years ago

This is the resulting netcdf.pc on 4.0.1, after a couple of fixes for upstream oddities.

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
ccompiler=gcc
cppcompiler=g++
fcompiler=gfortran
fflags=-g -O2 -I${includedir}
flibs=-lnetcdff -lnetcdf -L/usr/lib -lhdf5_hl -lhdf5  -lz -lm 

Name: netcdf
Description: NetCDF Client Library
Version: 4.1-beta2
Libs: -L${libdir} -lnetcdf -L/usr/lib -lhdf5_hl -lhdf5  -lz -lm 
Cflags: -I${includedir}

comment:3 by frankie, 15 years ago

The netcdf 3 (up to 3.6.3) never distributed a pkg-config file, so configure.ac should not rely on pkg-config only for a full support.

comment:4 by antonio, 13 years ago

Cc: antonio added

comment:5 by etourigny, 12 years ago

Owner: changed from chaitanya to etourigny
Version: 1.6.2unspecified

current trunk checks for hdf5 support automatically using nc-config script (only available for netcdf-4.x).

...
using libnetcdf from /home/softdev
checking libnetcdf version with /home/softdev/bin/ncdump... got 4.1.3
checking libnetcdf config with /home/softdev/bin/nc-config
checking for netcdf-4 (and HDF5) support in libnetcdf... yes
checking for HDF4 support in libnetcdf... yes
...

However, it doesn't add -lhdf5_hl -lhdf5 -lz, but it seems that these are not needed. At least in my setup (with hdf4 and hdf5 linked into gdal), they are automatically linked.

The command 'nc-config --libs' outputs the following (no hdf5 or -lz)

-L/home/softdev/lib -lnetcdf

According to INSTALL in netcdf-4.1.3 source, you don't need to include anything else than -lnetcdf for shared builds:

   For static build, to use netCDF-4 you must link to all the libraries,
netCDF, HDF5, zlib, and (if used with HDF5 build) szip. This will mean
-L options to your build for the locations of the libraries, and -l
(lower-case L) for the names of the libraries.

   For example, one user reports that she can build other applications
with netCDF-4 by setting the LIBS envoronment variable:

     LIBS='-L/X/netcdf-4.0/lib -lnetcdf -L/X/hdf5-1.8.6/lib -lhdf5_hl -lhdf5 -lz -lm -L/X/szip-2.1/lib -lsz'

   For shared builds, only -lnetcdf is needed. All other libraries will
be found automatically.

frankie: can you confirm current behavior is satisfactory?

comment:6 by etourigny, 12 years ago

Resolution: wontfix
Status: newclosed

Closing this bug, as I don't see the need for having netcdf3 and netcdf4 installed at the same time. Netcdf-4 can support the classic format and data model.

Use the --with-netcdf option to select a specific netcdf installation dir.

Note: See TracTickets for help on using tickets.