In order to help ld to find your hdf5 library you can add the following flag:
-L /usr/lib/x86_64-linux-gnu/hdf5/serial
i.e.
~$ gcc -lhdf5 -L/usr/lib/x86_64-linux-gnu/hdf5/serial
man gcc
-Ldir
Add directory dir to the list of directories to be searched for -l.
Official install instructions
Configure the HDF5 version
Note: this is a quick fix for a minor bug / issue with the version of libhdf5. If you know a better / proper way to solve it, let me know. If this section doesn't apply to you, omit it.
Go to the libraries directory:
cd /usr/lib/x86_64-linux-gnu
Set LD_LIBRARY_PATH for libraries in Anacoda, such as libhdf5.so.10, libhdf5_hl.so.10:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/ubuntu/anaconda/lib" >> ~/.bashrc
Update the "Dynamic Linker":
sudo ldconfig