forpy icon indicating copy to clipboard operation
forpy copied to clipboard

Anaconda and Ubuntu 20.04: libgfortran.so.4 not found

Open ylikx opened this issue 5 years ago • 1 comments

The problem

Using Ubuntu's gfortran 9 together with Anaconda can lead to the following error:

./a.out: error while loading shared libraries: libgfortran.so.4: cannot open shared object file: No such file or directory

This is because gfortran 9 wrongly links with the libgfortran installed in the conda environment, which is libgfortran.so.4 instead of libgfortran.so.5 that is used by gfortran 9.

Possible solutions

  1. Use Anaconda's gfortran (version 7): install with conda install gfortran_linux-64. Anaconda's compiler tools use some non-standard names for the compiler executables: you have to use x86_64-conda_cos6-linux-gnu-gfortran instead of gfortran. Use the -fno-lto option in the linking step, otherwise the linking step hangs.
  2. OR: install Ubuntu's gfortran-7 with sudo apt install gfortran-7 and use that.
  3. OR: use gfortran 9 and statically link libgfortran with the option -static-libgfortran in the linking step.
  4. OR: use gfortran 9 and temporarily rename conda's <path to anaconda>/lib/libgfortran.so to something else (similar to suggestion in https://github.com/igraph/rigraph/issues/275#issuecomment-408638236)

Probably not a good idea: Installing gfortran-7 or libgfortran4 and using gfortran 9 also seems to solve the problem for simple examples. However then the older libgfortran.so.4 is used instead of libgfortran.so.5

ylikx avatar Jun 28 '20 15:06 ylikx

Thank you!

naity2 avatar Mar 06 '23 22:03 naity2