Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in linking armadillo lapack blas to code: undefined reference to `dtrsm_ '

I am using armadillo as a wrapper framework for linear algebra routines which further uses linear algebra static libraries like lapack and blas.

I have manually compiled blas and lapack libraries and so as per readme.txt of armadillo, i am supposed to link to these two libraries at compile time. This is the gcc commandline i use -

g++ example2.cpp  -I../include/armadillo -L../lib/BLAS -lblas_LINUX -L../lib/lapack -   llapack_LINUX -lgfortran

This induces these errors -

../lib/lapack/liblapack_LINUX.a(dgetrf.o): In function `dgetrf_':
dgetrf.f:(.text+0x3da): undefined reference to `dtrsm_ '
../lib/lapack/liblapack_LINUX.a(dgetri.o): In function `dgetri_':
dgetri.f:(.text+0x286): undefined reference to `dswap_'
dgetri.f:(.text+0x609): undefined reference to `dtrsm_'

and more of these kind of errors.

Can anyone give me a suggestion to overcome this?

like image 438
new_web_programmer Avatar asked Nov 10 '13 17:11

new_web_programmer


1 Answers

You should first give the LAPACK library then the BLAS library:

g++ example2.cpp  -I../include/armadillo -L../lib/lapack -llapack_LINUX  -L../lib/BLAS -lblas_LINUX -lgfortran

LAPACK references routines in the BLAS library, and not the other way around; in this situation the LAPACK library must come first.

like image 91
Ali Avatar answered Oct 23 '22 09:10

Ali