[SOLVED] Linking old NetCDF to old HDF5 - undefined reference to `H5DSis_scale`

Hello. I’m trying to build some legacy software and move it away from spack. The relevant (I think) versions of the Spack libraries are:

hdf5-1.8.18
netcdf-4.4.0
netcdf-cxx4-4.3.0
netcdf-fortran-4.4.4

When I try to build netcdf-cxx4 I am getting errors like:

[ 24%] Linking C executable ncgen
ld: ../liblib/libnetcdf.so.4.3.0: undefined reference to `H5DSget_num_scales'
ld: ../liblib/libnetcdf.so.4.3.0: undefined reference to `H5DSis_scale'
ld: ../liblib/libnetcdf.so.4.3.0: undefined reference to `H5DSdetach_scale'
ld: ../liblib/libnetcdf.so.4.3.0: undefined reference to `H5DSset_scale'
ld: ../liblib/libnetcdf.so.4.3.0: undefined reference to `H5DSiterate_scales'
ld: ../liblib/libnetcdf.so.4.3.0: undefined reference to `H5DSattach_scale'
ld: ../liblib/libnetcdf.so.4.3.0: undefined reference to `H5DSget_scale_name'
ncgen/CMakeFiles/ncgen.dir/build.make:534: recipe for target 'ncgen/ncgen' failed
make[2]: *** [ncgen/ncgen] Error 1
CMakeFiles/Makefile2:1690: recipe for target 'ncgen/CMakeFiles/ncgen.dir/all' failed
make[1]: *** [ncgen/CMakeFiles/ncgen.dir/all] Error 2
Makefile:165: recipe for target 'all' failed
make: *** [all] Error 2

If I run nm libhdf5.so | grep H5D I get lots of strings returned, but none with the string scale in the name. nm libhdf5.so | grep H5D | grep scale has no response. How do I build libhdf5 v1.8.18 with these? I used these commands to build the current hdf5 I’m trying to link against:

git clone -b hdf5-1_8_18 git@github.com:HDFGroup/hdf5.git
cd hdf5

# --enable-cxx \ # not compatible with --enable-parallel
#  --enable-parallel \ # configure: error: unable to link a simple MPI-IO Fortran program

./configure \
  --prefix=${MY_ROOT}/opt/hdf5 \
  --enable-fortran \
  --enable-hl

make -j
make install

Can we see the link line? You must link against libhdf5_hl.[a,so]. You’ve enabled --enable-hl, and it should be there in lib with libhdf5.[a,so].

G.

I’m linking to hdf with

cmake .. \
  -DCMAKE_C_FLAGS=-fPIC \
  -DCMAKE_INSTALL_PREFIX=${MY_ROOT}/opt/netcdf-cxx4 \
  -DHDF5_INCLUDE_DIR=${MY_ROOT}/opt/hdf5/include \
  -DHDF5_HL_LIB=${MY_ROOT}/opt/hdf5/lib/libhdf5.so \
  -DHDF5_LIB=${MY_ROOT}/opt/hdf5/lib/libhdf5.so \

And cmake is happy (it finds it. But make is not.

I just found a clue though. The hdf5.so built with spack also does not have these symbols, so maybe I need to tell netcdf something via a flag so it doesn’t look for them…

That should point to the libhdf5_hl.so

1 Like

Doh! That fixed it. Thank you!