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

[netCDF #CAM-999479]: conflict between netcdf 4.1.1 and hdf5 1.8.4?



> Hello,
> 
> I'm trying to compile gdal (http://www.gdal.org/) with both netcdf4 and
> hdf5 support and finding a conflict between the netcdf and hdf5
> libraries.  I isolated a trivial test program which illustrates the problem:
> 
> char H5Fopen ();
> int
> main ()
> {
> return H5Fopen ();
> ;
> return 0;
> }
> 
> 
> compiling this program fails with complaints about undefined references:
> 
> [jcc@lion ~]$  gcc -o conftest -fPIC -fvisibility=hidden
> -I/usr/local/contrib/hdf5-1.8.4/include
> -I/usr/local/contrib/netcdf-4.1.1/include
> -L/usr/local/contrib/hdf5-1.8.4/lib
> -L/usr/local/contrib/netcdf-4.1.1/lib   -lnetcdf   -lhdf5  conftest.c
> 
> /usr/local/contrib/netcdf-4.1.1/lib/libnetcdf.so: undefined reference to
> `H5DSget_num_scales'
> /usr/local/contrib/netcdf-4.1.1/lib/libnetcdf.so: undefined reference to
> `H5DSset_scale'
> /usr/local/contrib/netcdf-4.1.1/lib/libnetcdf.so: undefined reference to
> `H5DSis_scale'
> /usr/local/contrib/netcdf-4.1.1/lib/libnetcdf.so: undefined reference to
> `H5DSiterate_scales'
> /usr/local/contrib/netcdf-4.1.1/lib/libnetcdf.so: undefined reference to
> `H5DSget_scale_name'
> /usr/local/contrib/netcdf-4.1.1/lib/libnetcdf.so: undefined reference to
> `H5DSattach_scale'
> /usr/local/contrib/netcdf-4.1.1/lib/libnetcdf.so: undefined reference to
> `H5DSdetach_scale'
> collect2: ld returned 1 exit status
> 
> 
> however, removing the "-lnetcdf" allows the compilation to succeed, e.g.
> 
> [jcc@lion ~]$  gcc -o conftest -fPIC -fvisibility=hidden
> -I/usr/local/contrib/hdf5-1.8.4/include
> -I/usr/local/contrib/netcdf-4.1.1/include
> -L/usr/local/contrib/hdf5-1.8.4/lib
> -L/usr/local/contrib/netcdf-4.1.1/lib   -lhdf5  conftest.c
> 
> 
> netcdf 4.1.1 was compiled w/ these options:
> export CFLAGS="-fPIC"
> 
> ./configure \
> --prefix=${CONTRIB}/netcdf-4.1.1 \
> --enable-netcdf-4 \
> --enable-cxx-4 \
> --enable-logging \
> --disable-dap \
> --disable-fortran \
> --with-udunits \
> --with-libcf \
> --with-hdf5=${CONTRIB}/hdf5-1.8.4 \
> --with-zlib=${CONTRIB}zlib-1.2.3 \
> --enable-shared
> 
> 
> hdf5 1.8.4 patch 1 was compiled w/ these options:
> export CFLAGS=-fPIC
> ./configure --prefix=${CONTRIB}/hdf5-1.8.4 \
> --with-zlib=${CONTRIB}/zlib-1.2.3
> --enable-shared
> 
> 
> Can you please help me understand why including the "-lnetcdf" would
> cause the failure and suggest a workaround?
> 
> Thanks!
> 
> --john
> 
> 

Howdy John!

For static builds (the default) you must specify the following:
-lnetcdf -lhdf5_hl -lhdf5 -lz

This is explained in more detail here:
http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-install/Linker-Flags.html#Linker-Flags

Please let me know if this doesn't work for you.

Thanks,

Ed

Ticket Details
===================
Ticket ID: CAM-999479
Department: Support netCDF
Priority: Normal
Status: Closed