# \[SOLVED\] Linking old NetCDF to old HDF5 - undefined reference to \`H5DSis\_scale\`

**URL:** <https://forum.hdfgroup.org/t/solved-linking-old-netcdf-to-old-hdf5-undefined-reference-to-h5dsis-scale/11018>\
**Category:** HDF5 Library\
**Created:** [April 11, 2023, 7:58pm UTC](https://forum.hdfgroup.org/t/solved-linking-old-netcdf-to-old-hdf5-undefined-reference-to-h5dsis-scale/11018 "2023-04-11T19:58:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mankoff](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/mankoff/32/1731_2.png) [@mankoff](https://forum.hdfgroup.org/u/mankoff)\
**Post date:** [April 11, 2023, 7:58pm UTC](https://forum.hdfgroup.org/t/solved-linking-old-netcdf-to-old-hdf5-undefined-reference-to-h5dsis-scale/11018/1 "2023-04-11T19:58:50Z")

</div>

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:

```auto
[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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![gheber](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/gheber/32/1919_2.png) [@gheber](https://forum.hdfgroup.org/u/gheber)\
**Post date:** [April 12, 2023, 11:04am UTC](https://forum.hdfgroup.org/t/solved-linking-old-netcdf-to-old-hdf5-undefined-reference-to-h5dsis-scale/11018/2 "2023-04-12T11:04:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mankoff](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/mankoff/32/1731_2.png) [@mankoff](https://forum.hdfgroup.org/u/mankoff)\
**Post date:** [April 12, 2023, 2:18pm UTC](https://forum.hdfgroup.org/t/solved-linking-old-netcdf-to-old-hdf5-undefined-reference-to-h5dsis-scale/11018/3 "2023-04-12T14:18:34Z")

</div>

I’m linking to hdf with

```auto
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…

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [April 12, 2023, 2:27pm UTC](https://forum.hdfgroup.org/t/solved-linking-old-netcdf-to-old-hdf5-undefined-reference-to-h5dsis-scale/11018/4 "2023-04-12T14:27:57Z")

</div>

> [@mankoff](#):
>
> -DHDF5\_HL\_LIB=${MY\_ROOT}/opt/hdf5/lib/libhdf5.so \

That should point to the libhdf5\_hl.so

---

<div class="post-metadata">

**Author:** ![mankoff](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/mankoff/32/1731_2.png) [@mankoff](https://forum.hdfgroup.org/u/mankoff)\
**Post date:** [April 12, 2023, 3:26pm UTC](https://forum.hdfgroup.org/t/solved-linking-old-netcdf-to-old-hdf5-undefined-reference-to-h5dsis-scale/11018/5 "2023-04-12T15:26:24Z")

</div>

Doh! That fixed it. Thank you!
