Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
6743 Discussions

Problems compiling Fortran with Lapack using MKL libraries in linux...

Javier_Gonzalez-plat
642 Views
I have a fortran program using the module mkl95_lapack.
My script for cstatic compilation is according with the information that I found in the intel documentation
-----------------------------------
#!/bin/bash
OPT="-c -O -w -vec-report0"
INC="-I$MKLROOT/include/ia32"
LIB="-L$MKLROOT/lib/ia32"
LIBOPT="-lmkl_lapack95 -Wl,--start-group $LIB/libmkl_intel.a $LIB/libmkl_sequential.a $LIB/libmkl_core.a -Wl,--end-group -lpthread"
ifort -c resolvedor.f90 -I/opt/intel/include/ia32 $INC
ifort -o lcicres resolvedor.o $LIBOPT
------------------------------------------------------
The compilation was ok because I have the object file but the link procedure fails and I have the next messages:

/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/ia32/libmkl_lapack95.a(cgetrf.o): In function `cgetrf_f95_':
../../../../interfaces/lapack95/source/cgetrf.f90:(.text+0x2ac): undefined reference to `cgetrf_'
../../../../interfaces/lapack95/source/cgetrf.f90:(.text+0x47f): undefined reference to `xerbla_'
/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/ia32/libmkl_lapack95.a(cgetrs1.o): In function `cgetrs1_f95_':
../../../../interfaces/lapack95/source/cgetrs1.f90:(.text+0x2a2): undefined reference to `cgetrs_'
../../../../interfaces/lapack95/source/cgetrs1.f90:(.text+0x345): undefined reference to `xerbla_'
/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/ia32/libmkl_lapack95.a(sgetrf.o): In function `sgetrf_f95_':
../../../../interfaces/lapack95/source/sgetrf.f90:(.text+0x29d): undefined reference to `sgetrf_'
../../../../interfaces/lapack95/source/sgetrf.f90:(.text+0x46a): undefined reference to `xerbla_'
/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/ia32/libmkl_lapack95.a(sgetrs1.o): In function `sgetrs1_f95_':
../../../../interfaces/lapack95/source/sgetrs1.f90:(.text+0x2d2): undefined reference to `sgetrs_'
../../../../interfaces/lapack95/source/sgetrs1.f90:(.text+0x404): undefined reference to `xerbla_'


Can anyone help me to resolve this problem?

Javier

0 Kudos
1 Solution
mecej4
Black Belt
642 Views
Ah, here is the problem:

In the definition line

LIB="-L$MKLROOT/lib/ia32"

the -L is the culprit. What it does is to tell the linker where to look for libraries, rather than specifying which libraries to link, which is what you want to do. The net effect of this error is to give a list of file paths rather than directory paths as places to search, and no extra libraries to be included in the link.

Simply change that line to

LIB="$MKLROOT/lib/ia32"

View solution in original post

6 Replies
mecej4
Black Belt
642 Views
The distribution of routines among the various component libraries in MKL has varied from one version to another. Which version of MKL did you use? Did you obtain the Lapack95 library from Intel? Precompiled?

Instead of specifying the MKL libraries explicitly, you could try the -mkl compiler option (you would still need to specify libmkl_lapack95.a explicitly).
Javier_Gonzalez-plat
642 Views
I'm using the last 10.3.
The options are takem from the link intel MKL advisor....

Javier
TimP
Black Belt
642 Views
Does you MKLROOT setting expand so as to match the actual path of your MKL installation?
Javier_Gonzalez-plat
642 Views
MKLROOT is
/opt/intel/composer_xe_2011_sp1.7.256/mkl
mecej4
Black Belt
643 Views
Ah, here is the problem:

In the definition line

LIB="-L$MKLROOT/lib/ia32"

the -L is the culprit. What it does is to tell the linker where to look for libraries, rather than specifying which libraries to link, which is what you want to do. The net effect of this error is to give a list of file paths rather than directory paths as places to search, and no extra libraries to be included in the link.

Simply change that line to

LIB="$MKLROOT/lib/ia32"
Javier_Gonzalez-plat
642 Views
Thanks!
Now works fine!

Thanks for all!

Javier
Reply