0
votes

I want to use the LAPACK library in my fortran code. I am compiling using gfortran and want to call the dgesv function from the lapack library.

I downloaded lapack3.5.0 and built it using Cmake which also tests it. The build for lapack3.5.0 has created the following libraries: libblas.a, liblapack.a, libtmglib.a

I am using a make file to compile my code using gfortran.

How do I use these libraries with gfortran compiler, I get error of dgsev being undefined when I compile. I have added the path to these libraries to the system path.

I have no clue what to do to use external libraries in gfortran.

1

1 Answers

2
votes

You have to use -L option of gfortran linker. Using this you will point the compiler to look for libraries in this path.

For example:

gfortran test.f -L/path/to/libs -llapack -lblas

If you have additional libraries you can setup like this

LLIBS  = -L/path/to/libs -llapack -lblas
XLIBS  = -L/usr/X11R6/lib64 -lX11 -lpthread 
GLIBS  = -L/usr/X11R6/lib64 -lGLU -lGL -lX11 -lXext -lpthread
OBJS   = test.o
gfortran $(OBJS) $(LLIBS) $(XLIBS) $(GLIBS)

There is no need to add anything to system path.