libhdf5 installation problem

6,788

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.

  1. Go to the libraries directory:

    cd /usr/lib/x86_64-linux-gnu
    
  2. 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
    
  3. Update the "Dynamic Linker":

    sudo ldconfig
    
Share:
6,788

Related videos on Youtube

Victor Poughon
Author by

Victor Poughon

Updated on September 18, 2022

Comments

  • Victor Poughon
    Victor Poughon over 1 year

    I've installed libhdf5-dev with apt-get but gcc cannot find it:

    ~$ locate libhdf5.so
    /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so
    ~$ gcc -lhdf5
    /usr/bin/ld: cannot find -lhdf5
    collect2: error: ld returned 1 exit status
    

    I'm on Ubuntu 17.10.

  • Victor Poughon
    Victor Poughon about 6 years
    Obviously I'm not using ld or gcc directly but a more complex build system
  • Victor Poughon
    Victor Poughon about 6 years
    Adding this path to the build library dir worked. But why doesn't ubuntu install this package in the correct location?
  • Yaron
    Yaron about 6 years
    seems like a known issue. I've added to my answer the official install instructions
  • Victor Poughon
    Victor Poughon about 6 years
    Thanks, I've fixed it by adding the search path to my build system config, which is a bit cleaner solution.