Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
12 Views

Undefined symbol errors

Hello Everyone,
I'm trying to modify some antiquated code to use a solver from the intel mkl and I'm having trouble getting ifort to correctly link the code. I had to compile my own copy of the f90 interface to work on my system, which is in ..../mkl/custom/lib/64 etc. Any insight that you can provide is most welcome!
Thanks,
Max
I try to compile with:
ifort bemech.f90 -heap_arrays -L$MKL_LIB -I$MKL_INC -Wl,--start-group $MKL_LIB/libmkl_lapack95_lp64.a -Wl,--end-group -lpthread -liomp5
The error that I receive is:
/data/64/max/sw/intel/ifc/mkl/custom/lib/64/libmkl_lapack95_lp64.a(sgetrf.o): In function `sgetrf_f95_':
source/sgetrf.f90:(.text+0x2b6): undefined reference to `sgetrf_'
source/sgetrf.f90:(.text+0x509): undefined reference to `xerbla_'
/data/64/max/sw/intel/ifc/mkl/custom/lib/64/libmkl_lapack95_lp64.a(sgetri.o): In function `sgetri_f95_':
source/sgetri.f90:(.text+0x28a): undefined reference to `sgetri_'
source/sgetri.f90:(.text+0x367): undefined reference to `xerbla_'
source/sgetri.f90:(.text+0x786): undefined reference to `sgetri_'
/data/64/max/sw/intel/ifc/mkl/custom/lib/64/libmkl_lapack95_lp64.a(sgetrs1.o): In function `sgetrs1_f95_':
source/sgetrs1.f90:(.text+0x332): undefined reference to `sgetrs_'
source/sgetrs1.f90:(.text+0x49f): undefined reference to `xerbla_'
/data/64/max/sw/intel/ifc/mkl/custom/lib/64/libmkl_lapack95_lp64.a(sgetrf.o): In function `sgetrf_f95_':source/sgetrf.f90:(.text+0x2b6): undefined reference to `sgetrf_'source/sgetrf.f90:(.text+0x509): undefined reference to `xerbla_'/data/64/max/sw/intel/ifc/mkl/custom/lib/64/libmkl_lapack95_lp64.a(sgetri.o): In function `sgetri_f95_':source/sgetri.f90:(.text+0x28a): undefined reference to `sgetri_'source/sgetri.f90:(.text+0x367): undefined reference to `xerbla_'source/sgetri.f90:(.text+0x786): undefined reference to `sgetri_'/data/64/max/sw/intel/ifc/mkl/custom/lib/64/libmkl_lapack95_lp64.a(sgetrs1.o): In function `sgetrs1_f95_':source/sgetrs1.f90:(.text+0x332): undefined reference to `sgetrs_'source/sgetrs1.f90:(.text+0x49f): undefined reference to `xerbla_'
The calling program looks like this:
SUBROUTINE INVSOLVR(NROW,NCOL,A,N,INDIC)
use f95_precision, only: wp => sp
use lapack95, only: getrf, getrs, getri
! Solve A x = y
! A array containing A
! NROW, NCOL rows and cols of A
! N number of equations
! After computation, A should contain inverse matrix and vector x
! INDIC = -1 : return just inverse of A
! INDIC = 0 : return inverse of A and x
! INDIC = 1 : return just x
INTEGER(KIND=4) :: IPIV(10000)
INTEGER(KIND=4) IERR
REAL(KIND=4) :: C(10000,10000)
REAL(KIND=4),DIMENSION (:), ALLOCATABLE :: Y
DIMENSION A(NROW,NCOL),W(N),IROW(N)
ALLOCATE(Y(N))
call GETRF( C, IPIV)
! C holds LU factorization of former C
call getrs( C, IPIV, Y, 'N', IERR)
! Y now contains solution.
0 Kudos
4 Replies
Highlighted
Valued Contributor I
12 Views

Hi,

You should add more MKL libraries, not just $MKL_LIB/libmkl_lapack95_lp64.a

Pleasetry Intel MKL Link Line Advisorat the top of MKL Forum to get correct list of MKL libraries
0 Kudos
Highlighted
Moderator
12 Views

Please change the order linking of the threading libraries : it should be-liomp5-lpthread
instead of"-lpthread -liomp5"
0 Kudos
Highlighted
Beginner
12 Views

I used the link line adviser and consequently used this compile command:
export MKLPATH=$MKLROOT/lib/intel64
ifort bemech.f90 -heap_arrays -I$MKL_INC -L$MKLPATH/libmkl_solver_ilp64.a -Wl,--start-group $MKLPATH/libmkl_intel_ilp64.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group -openmp -lpthread
Unfortunately, there are still undefined references, albeit different ones. Any ideas?
bash-3.2$ ./buildcmd.sh
/tmp/ifortcZUc3U.o: In function `el_solve_':
bemech.f90:(.text+0x1bc8b): undefined reference to `sgetrf_mkl95_'
bemech.f90:(.text+0x1bd61): undefined reference to `sgetrs1_mkl95_'
/tmp/ifortcZUc3U.o: In function `invsolvr_':
bemech.f90:(.text+0x24538): undefined reference to `sgetrf_mkl95_'
bemech.f90:(.text+0x2461a): undefined reference to `sgetrs1_mkl95_'
bemech.f90:(.text+0x246ec): undefined reference to `sgetri_mkl95_'
bemech.f90:(.text+0x24ba1): undefined reference to `sgetrf_mkl95_'
bemech.f90:(.text+0x24c86): undefined reference to `sgetrs1_mkl95_'
bash-3.2$
Thanks!
Max
0 Kudos
Highlighted
Beginner
12 Views

Never mind - I found the problem! The correct thing to do was to include mkl_lapack95_ilp64.a in addition to those above.
0 Kudos