Page 1 of 1

Undefined BLAS functions

PostPosted: Wed Apr 12, 2017 12:29 pm
by Mallo96
Hi everyone,

I am just getting started with Lapack but I am facing what I think to be a problem of linking. After having followed the main instructions indicated in http://www.netlib.org/lapack/lawnspdf/lawn81.pdf and ran positively the tests, I tried compiling a fortran code sent by a colleague with the following command :

gfortran -L/home/user/Desktop/LAPACK -I/home/user/Desktop/LAPACK/include -llapack -L/home/user/Desktop/LAPACK -I/home/user/Desktop/LAPACK/include -lblas -O3 codev4.f90 -o code_2.x -ffree-line-length-200

where the libraries (liblapack.a and libblas.a) are contained in /home/user/Desktop/LAPACK and I put all the header files in home/mallory/Desktop/LAPACK/include

I get the following errors :

/tmp/ccoALfwz.o: In function `testcorrelation_':
lorenz96v4.f90:(.text+0x132d): undefined reference to `dgemv_'
lorenz96v4.f90:(.text+0x171e): undefined reference to `dgemv_'
lorenz96v4.f90:(.text+0x1787): undefined reference to `dgemv_'
/tmp/ccoALfwz.o: In function `qr_':
lorenz96v4.f90:(.text+0x1da0): undefined reference to `dorm2r_'
lorenz96v4.f90:(.text+0x1dcb): undefined reference to `dgeqrf_'
/tmp/ccoALfwz.o: In function `rungekutta4thtl_':
lorenz96v4.f90:(.text+0x3653): undefined reference to `dgemm_'
lorenz96v4.f90:(.text+0x36bf): undefined reference to `dgemm_'
lorenz96v4.f90:(.text+0x3726): undefined reference to `dgemm_'
lorenz96v4.f90:(.text+0x375a): undefined reference to `dlaset_'
lorenz96v4.f90:(.text+0x3c88): undefined reference to `dgemm_'
lorenz96v4.f90:(.text+0x3cf4): undefined reference to `dgemm_'
lorenz96v4.f90:(.text+0x3d53): undefined reference to `dgemm_'
lorenz96v4.f90:(.text+0x3d84): undefined reference to `dlaset_'
/tmp/ccoALfwz.o: In function `MAIN__':
lorenz96v4.f90:(.text+0x8cd6): undefined reference to `dgemm_'
lorenz96v4.f90:(.text+0xa023): undefined reference to `dlaset_'
lorenz96v4.f90:(.text+0xa195): undefined reference to `ilaenv_'
lorenz96v4.f90:(.text+0xa276): undefined reference to `dgeqrf_'
lorenz96v4.f90:(.text+0xb343): undefined reference to `dlaset_'
lorenz96v4.f90:(.text+0xb4b5): undefined reference to `ilaenv_'
lorenz96v4.f90:(.text+0xbfa2): undefined reference to `dgeqrf_'
lorenz96v4.f90:(.text+0xc30d): undefined reference to `dtrtrs_'
lorenz96v4.f90:(.text+0xc399): undefined reference to `dnrm2_'
lorenz96v4.f90:(.text+0xceb5): undefined reference to `dorm2r_'
collect2: error: ld returned 1 exit status


It looks like the compiler doesn't find the header files as the functions are defined in there. Can anyone help me with that ?

Thank you very much !

Re: Undefined BLAS functions

PostPosted: Sun Apr 23, 2017 12:17 pm
by simon_wright
Could you try moving the -L and -l switches to the end of the command? (certainly -llapack, -lblas).

The problem may be that the linker only links objects from an archive if it knows it needs them, and if you put codev4.f90 after the libraries it’s too late.

You may need -lgfortran as well (right at the end!)

Re: Undefined BLAS functions

PostPosted: Mon May 15, 2017 6:29 am
by Julien Langou
Probably a mangling problem with fortran.
testcorrelation_ expects blas subroutines to have `one underscore`, like: dgemv_'
I would assume the blas subroutines in your blas libraries are mangled differently.
So maybe change compiler flags, etc.
Julien.

Re: Undefined BLAS functions

PostPosted: Wed Jun 21, 2017 2:13 pm
by ForrestC4
I am having the same issue on a Linux machine running Ubuntu 14.04 LTS. I am compiling my LAPACK and BLAS libraries using gfortran, and I am compiling my Fortran code using gfortran with the exact same compiler options used to make the LAPACK/BLAS libraries. I tried using the compiler option -fno-underscoring, but I got the exact same result and error message (sans underscores). I have followed the directions on creating the libraries to the letter, and I am unsure as to why they are not working properly. I have had no issues in the past compiling and using the libraries on Mac OSX using gfortran. Could there be an issue with the version of gfortran on my Linux machine, or am I still missing something in terms of compiler options? Thanks!