Skip to content

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

@ylikx

Description

@ylikx

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 igraph failing to compile due to missing libgfortran.so.4 (Arch based Linux) igraph/rigraph#275 (comment))

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions