You need to link the HDF5 library when compiling.
The errors you get mean the code for these functions is missing, because you didn't link the library file that contains them.
The easiest way is to compile using h5cc
as described in the tutorial you mentioned. Otherwise, if you prefer compiling in Eclipse, you need to search for the linker flags setting and add the correct flags which you can find by typing h5cc -show
in a terminal.
For instance, for me, h5cc -show
gives
clang -I/usr/local/include -L/usr/local/Cellar/hdf5/1.8.12/lib /usr/local/Cellar/hdf5/1.8.12/lib/libhdf5_hl.a /usr/local/Cellar/hdf5/1.8.12/lib/libhdf5.a -L/usr/local/lib -lsz -lz -ldl -lm
Piece by piece:
clang
is the compiler-I/usr/local/include
is a flag telling the compiler to search for header files inside the/usr/local/include
directory-L/usr/local/Cellar/hdf5/1.8.12/lib
and-L/usr/local/lib
are flags telling the linker to search for libraries inside these directories/usr/local/Cellar/hdf5/1.8.12/lib/libhdf5_hl.a
and/usr/local/Cellar/hdf5/1.8.12/lib/libhdf5.a
are the full path to two HDF5 static libraries (telling the linker to link them)-lsz
,-lz
,-ldl
and-lm
are flags telling the linker to link the librariessz
,z
,dl
andm
This is probably overkill. If your HDF5 is installed in a standard location, it might be enough to just add -lhdf5
to the linker flags.