Linking LAPACK/BLAS libraries

Posted by Daniel Bremberg on Stack Overflow See other posts from Stack Overflow or by Daniel Bremberg
Published on 2010-05-10T08:31:55Z Indexed on 2010/05/11 0:14 UTC
Read the original article Hit count: 613

Filed under:
|
|
|
|

Background:
I am working on a project written in a mix of C and Fortran 77 and now need to link the LAPACK/BLAS libraries to the project (all in a Linux environment). The LAPACK in question is version 3.2.1 (including BLAS) from netlib.org. The libraries were compiled using the top level Makefile (make lapacklib and make blaslib).

Problem:
During linking, error messages claimed that certain (not all) BLAS-routines called from LAPACK-routines were undefined. This gave me some headache but the problem was eventually solved when (in the Makefile) the order of appearance of the libraries to be linked was changed.

Code:
In the following, (a) gives errors while (b) does not. The linking is performed by (c).
(a) LIBS = $(LAPACK)/blas_LINUX.a $(LAPACK)/lapack_LINUX.a
(b) LIBS = $(LAPACK)/lapack_LINUX.a $(LAPACK)/blas_LINUX.a
(c) gcc -Wall -O -o $@ project.o project.a $(LIBS)

Question:
What could be the reason for the undefined references of only some routines and what makes the order of appearance relevant?

© Stack Overflow or respective owner

Related posts about linking

Related posts about blas