Dear all,
I am not able to build a “working” version of the HDF5 library in static form (in particular with fortran and parallel enabled, but I think this is not my issue). On the contrary, I can build and use the shared form successfully.
I am using CMake with the following flags:
CC=mpicc CXX=mpicxx FC=mpif90 cmake ../ \
-DCMAKE_INSTALL_PREFIX=$HDF5_PATH \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DBUILD_STATIC_LIBS:BOOL=ON \
-DHDF5_BUILD_FORTRAN:BOOL=ON \
-DHDF5_ENABLE_PARALLEL:BOOL=ON \
-DHDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16:BOOL=OFF \
-DCMAKE_ANSI_CFLAGS:STRING=-fPIC \
-DCMAKE_ANSI_FCFLAGS:STRING=-fPIC
$HDF5_PATH is a variable in my script. I am using OpenMPI (5.0.7) built with GCC (14.2.0).
With the above options, the HDF5 building seems to work smoothly, but when I try to build my program linking against this HDF5 library, I get errors in the linking phase about undefined references
like the following:
/usr/bin/ld: ./lib/libhdf5_fortran.a(H5_ff.F90.o): in function `__h5lib_MOD_h5get_free_list_sizes_f':
H5_ff.F90:(.text+0x4d4): undefined reference to `H5get_free_list_sizes'
...
My program links directly to ./lib/libhdf5_fortran.a (passing also -lz -ldl -lm), but it seems that the static library does not contain all the compiled objects necessary, e.g. H5Aff.o is one of the objects missing. I have also tried to pass all the .a libraries (libhdf5.a, libhdf5_hl.a, ecc…), but the undefined references persist.
On the contrary, building also the shared form of the HDF5 (changing DBUILD_SHARED_LIBS:BOOL=OFF option to ON) and using it to build my program works perfectly (in the linking phase, pass -lhdf5_fortran is enough).
In both shared and static cases, the path of the compiled HDF5 library is in my paths (PATH, LD_LIBRARY_PATH and LD_RUN_PATH).
I am almost sure that I am making some errors in building the static form, and it results in being incomplete, with some compiled objects missing.
Any suggestions are much more than welcome, thank you in advance.
Stefano