4
votes

I am trying to compile a program that uses lapack.

First, I installed lapack by installing all the packages using 'sudo apt-get install' on this link: https://launchpad.net/ubuntu/precise/+source/lapack

I am trying to compile the code on this page: http://www.nag.com/lapack-ex/examples/source/dgbsv-ex.f

I got this program from: http://www.nag.com/lapack-ex/lapack-ex.html

I tried to compile the program by typing

$gfortran dbgsv-ex.f -llapack -lblas

into a terminal

I get a bunch of error messages, all of the form

/usr/lib/gcc/i686-linux-gnu/4.6/../../../../lib/liblapack.so: undefined reference to         
`ATL_strsv'

i.e. the error messages end with ATL_xxxx. Note also that when I look in my /usr/lib/ I see a file called liblapack.so

1
Looks like your LAPACK library is built on ATLAS. Check if ATLAS is installed and add reference to -latlas or link directly with -llapack_atlas.Hristo Iliev
I installed atlas by typing sudo apt-get install libatlas-dev libatlas-doc libatlas-test libatlas-base-dev libatlas3gf-base libatlas-cpp-0.6-dev libatlas-cpp-0.6-1 libatlas-cpp-0.6-1-dbg Then tried to compile as before and got the same error messages, then I tried to compile by typing gfortran dbgsv-ex.f -L/usr/local/lib -llapack -lblas -latlas and I got an error saying /usr/bin/ld: cannot find -latlas In case the order mattered, I even tried to put -latlas before -lblas or before -llapack. I got the same error with -llapack_atlasdb1234
It appears to be some old bug in the Debian/Ubuntu packages. You can read more here.Hristo Iliev
I tried to change the alternatives using sudo update-alternatives --config libblas.so.3gf and similarly for lapack, but it still wasn't working. Is there some way I can get lapack working?db1234
I would suggest that you remove all BLAS and LAPACK related packages and reinstall ATLAS.Hristo Iliev

1 Answers

1
votes

As other comments already indicate, your system has an ATLAS implementation of LAPACK. The correct order of library linking (for the non-threaded version of ATLAS) would be then:

-llapack -lf77blas -lcblas -latlas

Also note, that your Fortran code seems to contain also a routine from the NAG Library (x04cef), so you would have to link the NAG Library as well.