Using lapack in fortran programs

Hi all
I have installed lapack library in my linux system using both pacman package manager and conda, but when i wanted to use its subroutines in my fortran programs i got error below:

$ gfortran test.f90

/home/linuxbrew/.linuxbrew/bin/ld: /tmp/ccmmwhkj.o: in function MAIN__': test.f90:(.text+0xdb): undefined reference to sgesv_’
collect2: error: ld returned 1 exit status

Hi @ELNS, you have to link against lapack such as

gfortran test.f90 -llapack

In the future, our Fortran Package Manger (fpm) will be able to do this for you, but for now you have to do it manually one way or another.

2 Likes

I have another question:
Should i mention all used libraries in your suggested command?
For example : $ gfortran test.f90 -l lapack blas

That depends on your Lapack installation. The syntax is -llapack -lblas.

1 Like

Thank you very mush :pray: :pray: :pray:
I am so glad that i am here.

2 Likes

We are happy to have you here!