[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #WOD-775615]: troubles compiling netcd4 with hdf4 support



Hi Tiziana,

Sorry to have taken so long to respond to your question ...
> I am trying to build the netcdf-4 (4.1.3) from source, with hdf5 and hdf4. 
> Unfortunately the build fails with the error below. It builds correctly if I 
> do not use the option --enable-hdf4
> 
> /bin/sh ../libtool --tag=CC   --mode=link gcc  -g -O2  -L/usr/local/lib -o 
> ncgen3 main.o load.o escapes.o getfill.o init.o genlib.o ncgentab.o 
> ../liblib/libnetcdf.la  -lhdf5_hl -lhdf5 -lm -lcurl
> libtool: link: gcc -g -O2 -o .libs/ncgen3 main.o load.o escapes.o getfill.o 
> init.o genlib.o ncgentab.o  -L/usr/local/lib ../liblib/.libs/libnetcdf.so 
> -L/usr/local//lib /usr/local/lib/libhdf5_hl.so /usr/local/lib/libhdf5.so 
> /usr/local/lib/libsz.so -lz -lrt -lm -lcurl -Wl,-rpath 
> -Wl,/usr/local/netcdf-4.1.3/lib
> ../liblib/.libs/libnetcdf.so: undefined reference to `SDstart'
> ../liblib/.libs/libnetcdf.so: undefined reference to `SDend'
> ../liblib/.libs/libnetcdf.so: undefined reference to `SDattrinfo'
> ../liblib/.libs/libnetcdf.so: undefined reference to `SDfileinfo'
> ../liblib/.libs/libnetcdf.so: undefined reference to `SDreadattr'
> ../liblib/.libs/libnetcdf.so: undefined reference to `SDselect'
> ../liblib/.libs/libnetcdf.so: undefined reference to `SDreaddata'
> ../liblib/.libs/libnetcdf.so: undefined reference to `SDdiminfo'
> ../liblib/.libs/libnetcdf.so: undefined reference to `SDgetfillvalue'
> ../liblib/.libs/libnetcdf.so: undefined reference to `SDgetinfo'
> ../liblib/.libs/libnetcdf.so: undefined reference to `SDgetdimid'
> collect2: ld returned 1 exit status
> make[2]: *** [ncgen3] Error 1
> make[2]: Leaving directory `/usr/local/netcdf-4.1.3/ncgen3'
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory `/usr/local/netcdf-4.1.3'
> make: *** [all] Error 2

It looks like the link command generated by libtool is missing a specification 
for where to find the installed HDF-4 library and include files.

According to the documentation for building with HDF-4 support:

  http://www.unidata.ucar.edu/software/netcdf/docs/build_hdf4.html

  ... The location for the HDF4 header files and library must be set 
  in the CPPFLAGS and LDFLAGS options.

So first check that the HDF4 library is actually in /usr/local/lib, rather
than /usr/local/hdf4/lib, for example, which is where it got installed on
my system, and similarly for the associated include files:

   /usr/local/hdf4/lib:
  drwxr-xr-x 2 root root    4096 Feb 28  2012 ./
  -rw-r--r-- 1 root root    1157 Feb 28  2012 libhdf4.settings
  drwxr-xr-x 6 root root    4096 Feb 28  2012 ../
  -rw-r--r-- 1 root root  264838 Feb 28  2012 libmfhdf.a
  -rwxr-xr-x 1 root root     876 Feb 28  2012 libmfhdf.la*
  -rw-r--r-- 1 root root 1218912 Feb 28  2012 libdf.a
  -rwxr-xr-x 1 root root     867 Feb 28  2012 libdf.la*

  /usr/local/hdf4/include:
  drwxr-xr-x 6 root root  4096 Feb 28  2012 ../
  drwxr-xr-x 2 root root  4096 Feb 28  2012 ./
  -rw-r--r-- 1 root root  3280 Feb 28  2012 hdf2netcdf.h
  -rw-r--r-- 1 root root 15519 Feb 28  2012 hdf4_netcdf.h
   ...

> These are the commands I used for building:
> 
> export FC=/opt/pgi/linux86-64/12.9/bin/pgf90
> export F77=/opt/pgi/linux86-64/12.9/bin/pgf90
> export LD_LIBRARY_PATH=/usr/local/lib
> export CPPFLAGS=-I/usr/local/include
> export LDFLAGS=-L/usr/local/lib
> export LD_LIBRARY_PATH=/usr/local/lib
> ./configure --enable-hdf4 --with-udunits --prefix=/usr/local/netcdf-4.1.3/
> 
> The szlib, zlib, hdf4 and hdf5 are all in /usr/local/lib
> 
> The szlib were built as:
> ./configure --prefix=/usr/local
> 
> The hdf4 were built as:
> ./configure --with-zlib=/usr/local --with-szlib=/usr/local/ 
> --with-jpeg=/usr/local/jpeg-6b/ --disable-netcdf --prefix=/usr/local
> 
> The hdf5 were built as:
> ./configure --with-zlib=/usr/local --with-szlib=/usr/local/ --enable-fortran 
> --prefix=/usr/local

--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: WOD-775615
Department: Support netCDF
Priority: Critical
Status: Closed