Dear HDF experts!
Sorry for my frequent noises…
As I said before, now I’m developing a (hopefully portable) CMakeLists.txt
file for our pure-Fortran project which partly depends on the HDF5 library. It should be able to switch on/of static linking for a reason.
At present, thanks to the precompiled HDF5 binaries hdf5-1.14.6-win-vs2022_intel.msi and hdf5-1.14.6-ubuntu-2404_intel.tar.gz, it works (=static linking can be switch on and off) on windoze and Ubuntu w/ Intel Fortran compiler.
It works also with distro-packaged HDF5 libraries on Ubuntu 24.04 (libhdf5-fortran-102t64 (1.10.10+repack-3.1ubuntu4), gfortran ver.13) and Fedora 42 (hdf5 (1.14.6-3.fc42), gfortran ver.15).
But I think gfortran-15 has a bug in allocatable character array and it can’t be used for our project at present. Therefore, at least on recent Fedora machines I have to build HDF5 library by myself with Intel Compiler or older versions of gfortran.
The build of the HDF5 libraries using CMake with either of the above compilers (with /usr/lib64/libz.a
, /usr/local/lib64/libaec.a
, and /usr/local/lib64/libsz.a
installed on the system) was finished more or less successfully and they were installed with the resultant(cpack) shell script . With the self-built HDF5 libralies, the same CMakeLists.txt
also works when dynamically linking, but does NOT work for statical linking. When configuring static linking, CMake complains that:
CMake Error at /home/furutaka/work/HDF5/hdf5-1.14.6-bld-serial-cmake-gf14/HDF_Group/HDF5/1.14.6/cmake/hdf5-targets.cmake:59 (set_target_properties):
The link interface of target "hdf5-static" contains:
ZLIB::ZLIB
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
/home/furutaka/work/HDF5/hdf5-1.14.6-bld-serial-cmake-gf14/HDF_Group/HDF5/1.14.6/cmake/hdf5-config.cmake:175 (include)
/usr/share/cmake/Modules/FindHDF5.cmake:513 (find_package)
CMakeLists.txt:76 (find_package)
Could some experts teach me why/how this occurs, please? How can I fix/resolve this?
By adding find_package(ZLIB REQUIRED)
and find_package(libaec CONFIG)
in CMakeLists.txt
, the CMake configuration finishes without the complaint, but even with set(ZLIB_USE_STATIC_LIBS ON)
and set(libaec_USE_STATIC_LIBS ON)
these libraries are dynamically linked…
How can I configure and build the library which works in the same/equivalent way as hdf5-1.14.6-ubuntu-2404_intel.tar.gz, which contains libaec.a
, libszaec.a
and libzlib-static.a
in it?
Thanks in advance…
Kazuyoshi