Building HDF5 1.10.1 with CMake on a Cray XC40 -> ../../bin/, needed by, not found

Dear HDF-Forum,

I experience a linking problem using HDF5 after I build it from source. I used the git branch "hdf5_1_10_1".
The file seem to be hard linked to a non-existing ../../bin/

the first hint to the problem was during the build of HDF5 already. I got this warning:
/usr/bin/ld: warning: ../../bin/, needed by ../../../bin/, not found (try using -rpath or -rpath-link)
And other similar warnings.

and also while building my own program that uses HDF5, I got the warning again:
/usr/bin/ld: warning: ../../bin/, needed by /home/h/nikknoop/opt/hdf5/lib/, not found (try using -rpath or -rpath-link)
and at runtime my own program crashed, after the warning not surprising, with:
./executable: error while loading shared libraries: ../../bin/ cannot open shared object file: No such file or directory

A quick ldd of the actual /home/h/nikknoop/opt/hdf5/lib/ returns:
$ ldd => (0x00002aaaaaaab000)
         ../../bin/ => not found => /lib64/ (0x00002aaaaad50000) => /lib64/ (0x00002aaaaafc9000) => /lib64/ (0x00002aaaab1cd000)
         /home/h/nikknoop/opt/zlib/lib/ (0x00002aaaab3d7000)
         /home/h/nikknoop/opt/szip/lib/ (0x00002aaaab5f1000) => /opt/cray/rca/default/lib64/ (0x00002aaaab808000) => /lib64/ (0x00002aaaaba0d000) => /lib64/ (0x00002aaaabc2a000)
         /lib64/ (0x0000555555554000)

and an objdump of the library returns:
$ objdump -x | grep
    NEEDED ../../bin/
$ objdump -x | grep RPATH
   RPATH /opt/cray/gcc-libs

I wondered why the heck is searched for in "../../bin/" instead of "<install_prefix>/lib/" where it actually is installed?

I found in the HDF5 CMake build log the following line:
[ 72%] Linking C shared library ../bin/
That looks familiar, but I would expect cmake to rewrite the linking during installation.

So could it be that CMake failed to care for correct linking at install time. After all, all the other links are correct:

$ objdump -x | grep NEEDED
   NEEDED /home/h/nikknoop/opt/zlib/lib/
   NEEDED /home/h/nikknoop/opt/szip/lib/

$ objdump -x | grep RPATH
   RPATH /opt/cray/gcc-libs

I used the following cmake commands to configure and build hdf5:

$ cmake \
       -C "${source_dir}/config/cmake/cacheinit.cmake" \
       -DCMAKE_INSTALL_PREFIX:PATH=/home/h/nikknoop/opt/hdf5 \
       -DCMAKE_FIND_ROOT_PATH:PATH=/home/h/nikknoop/opt/szip \
       -DCMAKE_BUILD_TYPE:STRING="Release" \
       -DCMAKE_SYSTEM_NAME=CrayLinuxEnvironment \
       -G "Unix Makefiles" \
       -DCMAKE_C_COMPILER=cc \
       -DCMAKE_INSTALL_RPATH:STRING="/home/h/nikknoop/opt/hdf5/lib" \
       -DSZIP_INCLUDE_DIR:PATH=/home/h/nikknoop/opt/szip/include \
-DSZIP_LIBRARY:FILEPATH=/home/h/nikknoop/opt/szip/lib/ \
       -DZLIB_ROOT:PATH=/home/h/nikknoop/opt/zlib \
       -DMPIEXEC:STRING=mpirun \
       -Wno-dev \

$ cmake --build ${build_dir} --target install -- -j4

Attached to this mail please find the complete cmake configure and build logs and the CMakeCache.txt

I am using CMake version 3.9.0.

Can anyone help me solve this problem please? Preferably, I would like to have the rpath set the correct way withing the library file itself. I would prefer not to use LD_LIBRARY_PATH.
Please tell me if you need more information!

Best regard and thank you in advance for your help,

CMakeCache.txt (58.7 KB)

stdout_cmake_build.txt (1.41 MB)

stdout_cmake_configure.txt (14.4 KB)


M.Sc. Helge Knoop
Leibniz Universität Hannover
Institut fuer Meteorologie und Klimatologie
Herrenhaeuser Str. 2
30419 Hannover
Tel. +49 511 762 19238