I was trying to compile my code with Intel Fortran compiler in Ubuntu 20. My code needs HDF5 library, which I compiled separately, and I added the HDF5 library into LD_LIBRARY_PATH
.After that, my LD_LIBRARY_PATH
looks like this:
$ echo $LD_LIBRARY_PATH
/opt/intel/oneapi/tbb/2021.9.0/env/../lib/intel64/gcc4.8:/opt/intel/oneapi/rkcommon/1.11.0/lib:/opt/intel/oneapi/ospray_studio/0.12.0/lib:/opt/intel/oneapi/ospray/2.11.0/lib:/opt/intel/oneapi/openvkl/1.3.2/lib:/opt/intel/oneapi/oidn/1.4.3/lib:/opt/intel/oneapi/mpi/2021.9.0//libfabric/lib:/opt/intel/oneapi/mpi/2021.9.0//lib/release:/opt/intel/oneapi/mpi/2021.9.0//lib:/opt/intel/oneapi/mkl/2023.1.0/lib/intel64:/opt/intel/oneapi/itac/2021.9.0/slib:/opt/intel/oneapi/ispc/1.19.0/lib:/opt/intel/oneapi/ipp/2021.8.0/lib/intel64:/opt/intel/oneapi/ippcp/2021.7.0/lib/intel64:/opt/intel/oneapi/ipp/2021.8.0/lib/intel64:/opt/intel/oneapi/embree/4.0.1/lib:/opt/intel/oneapi/dnnl/2023.1.0/cpu_dpcpp_gpu_dpcpp/lib:/opt/intel/oneapi/debugger/2023.1.0/gdb/intel64/lib:/opt/intel/oneapi/debugger/2023.1.0/libipt/intel64/lib:/opt/intel/oneapi/debugger/2023.1.0/dep/lib:/opt/intel/oneapi/dal/2023.1.0/lib/intel64:/opt/intel/oneapi/compiler/2023.1.0/linux/lib:/opt/intel/oneapi/compiler/2023.1.0/linux/lib/x64:/opt/intel/oneapi/compiler/2023.1.0/linux/lib/oclfpga/host/linux64/lib:/opt/intel/oneapi/compiler/2023.1.0/linux/compiler/lib/intel64_lin:/opt/intel/oneapi/ccl/2021.9.0/lib/cpu_gpu_dpcpp:“:/home/samz/local/lib/phdf5/1.8.23/build_ifort_2021_impi_2021/lib”
However, when I run my code, the Intel fortran compiler complains:
./****.exe: error while loading shared libraries: libhdf5_fortran.so.10: cannot open shared object file: No such file or directory
Whereas libhdf5_fortran.so.10
is in the /home/samz/local/lib/phdf5/1.8.23/build_ifort_2021_impi_2021/lib
directory:
$ ls -la /home/samz/local/lib/phdf5/1.8.23/build_ifort_2021_impi_2021/lib
total 11420
drwxrwxr-x 2 samz samz 4096 Apr 10 14:35 .
drwxrwxr-x 6 samz samz 4096 Apr 10 14:35 ..
-rw-r--r-- 1 samz samz 6763194 Apr 10 14:35 libhdf5.a
-rw-r--r-- 1 samz samz 419748 Apr 10 14:35 libhdf5_fortran.a
-rwxr-xr-x 1 samz samz 1115 Apr 10 14:35 libhdf5_fortran.la
lrwxrwxrwx 1 samz samz 25 Apr 10 14:35 libhdf5_fortran.so -> libhdf5_fortran.so.10.0.8
lrwxrwxrwx 1 samz samz 25 Apr 10 14:35 libhdf5_fortran.so.10 -> libhdf5_fortran.so.10.0.8
-rwxr-xr-x 1 samz samz 341456 Apr 10 14:35 libhdf5_fortran.so.10.0.8
-rw-r--r-- 1 samz samz 229896 Apr 10 14:35 libhdf5_hl.a
lrwxrwxrwx 1 samz samz 19 Apr 10 14:35 libhdf5_hl_fortran.a -> libhdf5hl_fortran.a
-rw-r--r-- 1 samz samz 127576 Apr 10 14:35 libhdf5hl_fortran.a
-rwxr-xr-x 1 samz samz 1292 Apr 10 14:35 libhdf5hl_fortran.la
lrwxrwxrwx 1 samz samz 20 Apr 10 14:35 libhdf5_hl_fortran.so -> libhdf5hl_fortran.so
lrwxrwxrwx 1 samz samz 27 Apr 10 14:35 libhdf5hl_fortran.so -> libhdf5hl_fortran.so.10.0.7
lrwxrwxrwx 1 samz samz 27 Apr 10 14:35 libhdf5hl_fortran.so.10 -> libhdf5hl_fortran.so.10.0.7
-rwxr-xr-x 1 samz samz 106024 Apr 10 14:35 libhdf5hl_fortran.so.10.0.7
-rwxr-xr-x 1 samz samz 1080 Apr 10 14:35 libhdf5_hl.la
lrwxrwxrwx 1 samz samz 20 Apr 10 14:35 libhdf5_hl.so -> libhdf5_hl.so.10.2.4
lrwxrwxrwx 1 samz samz 20 Apr 10 14:35 libhdf5_hl.so.10 -> libhdf5_hl.so.10.2.4
-rwxr-xr-x 1 samz samz 163408 Apr 10 14:35 libhdf5_hl.so.10.2.4
-rwxr-xr-x 1 samz samz 983 Apr 10 14:35 libhdf5.la
-rw-r--r-- 1 samz samz 6699 Apr 10 14:35 libhdf5.settings
lrwxrwxrwx 1 samz samz 17 Apr 10 14:35 libhdf5.so -> libhdf5.so.10.4.1
lrwxrwxrwx 1 samz samz 17 Apr 10 14:35 libhdf5.so.10 -> libhdf5.so.10.4.1
-rwxr-xr-x 1 samz samz 3491568 Apr 10 14:35 libhdf5.so.10.4.1
Then I used the option export LD_DEBUG=all
to debug the problem and figured out the problem was that the added HDF5 library path is not actually checked. Here are the extracts from the output of the LD_DEBUG mode:
...
126670: search path=/opt/intel/oneapi/tbb/2021.9.0/env/../lib/intel64/gcc4.8:/opt/intel/oneapi/rkcommon/1.11.0/lib:/opt/intel/oneapi/ospray_studio/0.12.0/lib:/opt/intel/oneapi/ospray/2.11.0/lib:/opt/intel/oneapi/openvkl/1.3.2/lib:/opt/intel/oneapi/oidn/1.4.3/lib:/opt/intel/oneapi/mpi/2021.9.0//libfabric/lib:/opt/intel/oneapi/mpi/2021.9.0//lib/release:/opt/intel/oneapi/mpi/2021.9.0//lib:/opt/intel/oneapi/mkl/2023.1.0/lib/intel64:/opt/intel/oneapi/itac/2021.9.0/slib:/opt/intel/oneapi/ispc/1.19.0/lib:/opt/intel/oneapi/ipp/2021.8.0/lib/intel64:/opt/intel/oneapi/ippcp/2021.7.0/lib/intel64:/opt/intel/oneapi/embree/4.0.1/lib:/opt/intel/oneapi/dnnl/2023.1.0/cpu_dpcpp_gpu_dpcpp/lib:/opt/intel/oneapi/debugger/2023.1.0/gdb/intel64/lib:/opt/intel/oneapi/debugger/2023.1.0/dep/lib:/opt/intel/oneapi/dal/2023.1.0/lib/intel64:/opt/intel/oneapi/compiler/2023.1.0/linux/lib:/opt/intel/oneapi/compiler/2023.1.0/linux/lib/x64:/opt/intel/oneapi/compiler/2023.1.0/linux/lib/oclfpga/host/linux64/lib:/opt/intel/oneapi/compiler/2023.1.0/linux/compiler/lib/intel64_lin:/opt/intel/oneapi/ccl/2021.9.0/lib/cpu_gpu_dpcpp:“/tls/haswell/x86_64:“/tls/haswell:“/tls/x86_64:“/tls:“/haswell/x86_64:“/haswell:“/x86_64:“ (LD_LIBRARY_PATH)
...
I was able to work around by creating links to the HDF5 library at the directories that are actually checked by the code. But wondering why changing the LD_LIBRARY_PATH did not work?
I loaded the Intel environment in .bashrc
via . /opt/intel/oneapi/setvars.sh > /dev/null
Appreciate your helps. Thank you.