Lgfortran not found

I am using Ubuntu 10.04 and trying to compile code that uses gfortran. At some point, the Makefiles does:

-L. -lgfortran 

and I get an error

 /usr/bin/ld: cannot find -lgfortran 

although it is installed:

 ldconfig -p | grep fortran libgfortran.so.3 (libc6,x86-64) => /usr/lib/libgfortran.so.3 

How can i fix this?

PS: Makefile:

 ## FLAGS CC:= gcc C++:= g++ CFLAGS:= -c -O -Dintel -g FC:= gfortran FFLAGS:= -c -O -cpp -g LD:= g++ LDFLAGS:= -O WETTER_CGAL_FLAGS:= -g #WETTER-Data WETTER_cgal: weather.cpp surface_alg.h $(WETTER_CGAL_OBJECTS) WATT_interface.h data.cpp $(C++) $(WETTER_CGAL_FLAGS) -c weather.cpp -frounding-math $(C++) -c data.cpp -frounding-math $(LD) $(WETTER_CGAL_OBJECTS) weather.o data.o -o WETTER_cgal -L. -lgfortran -lgmp -lCGAL -frounding-math -fp-model 
+10
fortran linker ubuntu gfortran makefile
source share
5 answers

For some reason, is your version of gfortran different from the version of your g++ ? Or maybe it is installed elsewhere?

The -lname parameter (in this case name is gfortran ) tells the linker to search for the library file named libname.a in the library search path. If it is found and static binding is not applied using the parameter -[B]static , the linker will again look for libname.so and instead refer to it (if it is found). If libname.a not found, an error will be libname.so despite the presence of libname.so .

In your installation, gfortran should be libgfortran.a . Find it with find and specify 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 the static C / C ++ libraries and Fortran are in the same place). It will not be present if both compilers differ in their version.

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

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

Option -L. rather associated with -lCGAL than with -lgfortran .

+12
source share

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

+5
source share

Just make sure you:

 gcc --version 

and

 gfortan --version 

Same.

 /usr/bin/ 

Contains various versions.

For example: If gcc--version returns 4.7.3 and gfortran --version 4.8 , a simple hack may be as follows:

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

It should work.

+3
source share

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

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

+3
source share

How to do it?

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

0
source share

All Articles