Ubuntu – Error loading share libraries: libgfortran.so.3 under Ubuntu 18.04.1

shared library

I recently installed Ubuntu 18.04.1. Now, when I try to run a mpi Fortran code, there is an error loading the shared library: libgfortran.so.3 and the code does not execute. I tried to reinstall gfortran, mpich, and gcc by removing the software, but I cannot remove them using sudo apt-get remove gfortran because the removal aborts when I am asked whether I want to continue. When I try to make an executable, an unknown file type is generated for the executable.

Best Answer

According to packages.ubuntu.com you should install libgfortran3 package, as it contains /usr/lib/x86_64-linux-gnu/libgfortran.so.3:

sudo apt-get install libgfortran3

Note: if your software is 32-bit, then install two corresponding packages:

sudo apt-get install lib32gfortran3 libx32gfortran3