Linking LAPACK with ifort

Post here if you have a question about linking your program with LAPACK or ScaLAPACK library

Linking LAPACK with ifort

Postby turnabu » Wed Jan 09, 2013 7:59 am

Hi,
As a newbie to both linux and command line Fortran I hit a rock so quickly. After building the blas and lapack libraries (I'm using the Intel fortran compiler), I try to link them with the source files through the command (the libraries liblapack.a and libblas.a are located at the same path with the source files)
Code: Select all
ifort -llapack -lblas *.f90

and the result is
Code: Select all
ld: cannot find -llapack
However, if the libraries are introduced with the -L option, the error message now indicates that the source file cannot find the lapack routines it looks for, e.g.,
Code: Select all
num_pack.f90:(.text+0x209): undefined reference to `dgeev_'

Can you give a hint about what I'm doing wrong? Thank you for your replies in advance.
turnabu
 
Posts: 2
Joined: Tue Jan 08, 2013 9:35 am

Re: Linking LAPACK with ifort

Postby admin » Thu Jan 10, 2013 12:47 am

When linking, the order, and the names of your libraries matter.
Something like
Code: Select all
ifort *.f90 -o myexe -L. -llapack -lblas
will work if the names of the libraries are liblapack.a and libblas.a, and they are in the same folder than your f90 files.
The -L option is used to indicate the path of the libraries,
Otherwise because your lib are in your directory you can simply give the full name:
Code: Select all
ifort *.f90 -o myexe liblapack.a libblas.a

FYI, Intel has its own optimized LAPACK and BLAS library: MKL, that should give you better performance.
Hope it helps
admin
Site Admin
 
Posts: 501
Joined: Wed Dec 08, 2004 7:07 pm

Re: Linking LAPACK with ifort

Postby turnabu » Fri Jan 11, 2013 5:00 am

Thank you for your helpful reply. Now, everything works as it's supposed to be.
I've already used the mkl library or implement the
Code: Select all
sudo opt-get install liblapack-dav
command (I'm using Ubuntu) for building the LAPACK library just to see the working of system, but since my main goal is compiling the LAPACK in quad precision, I should learn the whole process rather than rely on ready solutions [of course, there may also be available libraries for this purpose -quad precision- that I'm not aware of:) ]
turnabu
 
Posts: 2
Joined: Tue Jan 08, 2013 9:35 am


Return to Linking Problem

Who is online

Users browsing this forum: Bing [Bot] and 0 guests

cron