lgfortran not found

Just make sure you:

gcc --version

And

gfortan --version

Is the same.

/usr/bin/ 

Contains the different versions.

Eg: If gcc--version returns 4.7.3 and gfortran --version 4.8, a simple hack could be to do the following.

sudo cp /usr/bin/gcc-4.8 /usr/bin/gcc

It should work.


I had the same problem and tried the following command. The problem was solved using this:

sudo ln -s /usr/lib/x86_64-linux-gnu/libgfortran.so.3 /usr/lib/libgfortran.so


Does by any chance your gfortran version differ from the version of your g++? Or maybe it is installed in a different location?

The -lname option (in this case name is gfortran) instructs the linker to search for a library file called libname.a in the library search path. If found and no static linking is enforced by the -[B]static option the linker will search once again for libname.so and link against it instead (if found). If libname.a is not found an error will be given despite the presence of libname.so.

There should be a libgfortran.a somewhere in your gfortran installation. Search for it with find and provide the path to g++ with -L/path/to/compiler/libs. If g++ is the same version as your gfortran the path to libgfortran.a will already be present in the library search path (since both C/C++ and Fortran static libraries reside in the same place). It will not be present if both compilers differ in their version though.

For example on a 64-bit RedHat based system libgfortran.a is located in /usr/lib/gcc/x86_64-redhat-linux/<GCC version>/ while the shared libgfortran.so.* are located in /usr/lib64.

An alternative solution is to replace -lgfortran with /usr/lib/libgfortran.so.3.

The -L. option is rather related to -lCGAL than to -lgfortran.


I had the same issue today when compiling ATLAS and was able to fix it using a symbolic link from libgfortran.so.3 to libgfortran.so.