Thursday, November 24, 2011

Cannot find -llapack when doing /usr/bin/ld on CentOS 5

I encountered an error when one of our researchers did a compilation of a Fortran Program which requires blas and lapack

$ g77 test.f  -L/usr/lib64/ -llapack -lblas
/usr/bin/ld: cannot find -llapack
collect2: ld returned 1 exit status

I was quite puzzled as I have installed lapack and blas. And it seems that lapack is having issues

To check whether you have the libraries, you can use the command
$ ldconfig -p | grep llapack (libc6,x86-64) => /usr/lib64/ (libc6,x86-64) => /usr/lib64/
So it is not an issue of missing lapack libraries. It is there.

           "On systems which support shared libraries, ld may also search for libraries with exten-
           sions other than ".a".  Specifically, on ELF and SunOS systems, ld will search a direc-
           tory  for  a library with an extension of ".so" before searching for one with an exten-
           sion of ".a".  By convention, a ".so" extension indicates a shared library.

           The linker will search an archive only once, at the location where it is  specified  on
           the  command  line.  If the archive defines a symbol which was undefined in some object
           which appeared before the archive on the command line,  the  linker  will  include  the
           appropriate  file(s)  from  the  archive.   However,  an  undefined symbol in an object
           appearing later on the command line will not cause the linker  to  search  the  archive

So just do a quick soft-links and the problem was solved
$ ln -s /usr/lib64/ /usr/lib64/

1 comment:

Unknown said...

Thanks so much for your valuable post,

I installed lapack through the package manager. I could not figure out why it wasn't recognized when compiling.

Your trick solved this issue.