Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

lapack95 linking problems

mike-s
Beginner
2,195 Views

Hi,

I have the following piece of code,

subroutine inv(A,N)

use mkl95_lapack
use mkl95_precision
real(kind=8) :: A(N,N)
integer :: ipiv(N)
call getrf(A,ipiv)
call getri(A,ipiv)
end subroutine

When I try to compile it I get an linker error,

undefined reference to `dgetrf_mkl95_' . My ifort options are

/opt/intel/Compiler/current//bin/intel64/ifort -O -X -p -module ../out-intel-x86_64/
-L/opt/intel/Compiler/current//mkl/lib/em64t/
-Wl,--start-group -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group
-openmp -lpthread -L/opt/intel/Compiler/current/mkl/lib/em64t/ -lmkl_lapack95_lp64
-L/opt/intel/Compiler/current//lib/intel64/ -Belf64-x86-64 -i-dynamic
-L/opt/intel/Compiler/current//mkl/lib/em64t/ -o ../out-intel-x86_64/test.exe

It seems to me that the problem is in the/opt/intel/Compiler/current//mkl/lib/em64t//libmkl_solver_lp64.a where the function dgetrf_mkl95_ is defined in the file dgetrf.o however it is not found. Any ideas?

Regards,

Mike

0 Kudos
1 Solution
barragan_villanueva_
Valued Contributor I
2,195 Views

Mike,

Please use-lmkl_lapack95_lp64 instead of -lmkl_lapack and source file before libraries.

So, correct link line is as follows:

ifort -I$MKLROOT/include/em64t/lp64 test.f90 -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5

View solution in original post

0 Kudos
10 Replies
TimP
Honored Contributor III
2,195 Views

ld does static library recursive searches only in the group of libraries surrounded by start-group .... end-group.

If you are using a recent version of ifort, installing it normally and sourceing the ifortvars script will take care of the -L paths, if you are using (default) dynamic libraries. It still would be much better to specify the options in order.

If you want to find out which options are used and which are dropped when you randomize the order, perhaps the ifort -# option would help.

0 Kudos
barragan_villanueva_
Valued Contributor I
2,195 Views

Hi,

Please take a look at similar discussion:http://software.intel.com/en-us/forums/showthread.php?t=72004

0 Kudos
mike-s
Beginner
2,195 Views

Hi,

thanks for the link. The only thing I found there that he apparantly has an libmkl_lapack95, which I do not have as a 64bit lib. From the docu I understand that those libs are split up in bigint and normal int libs with the suffixes ilp64 and lp64, so I guess that this is not a problem.

As tim18 suggested, I cleaned up my library search paths which now looks like

MKLPATH = /opt/intel/Compiler/current/mkl/lib/em64t/
LDFLAGS+= -Wl,--start-group \
-L $(MKLPATH) \
-lmkl_lapack -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group
LDFLAGS+= -openmp -lpthread
LDFLAGS+= -Wl,--start-group $(MKLPATH)/libmkl_lapack95_lp64.a -Wl,--end-group

Since the module is found and nm tells me that the subroutine dgetrf_mkl95_ is in the file libmkl_lapack95_lp64 I am kind of lost why ifort does not find it. Any ideas?

Regards,

Mike

0 Kudos
csnatarajan
Beginner
2,195 Views

Hi Mike, assuming that $(LD_LIBRARY_PATH) contains your lib path for mkl em64t this line should work, I just tried a compiling a simple lapack95 code and everything went ok!

ifort code.f -I(MKL_ROOT)/include/em64t/lp64/ -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5

Cheers,

C.S.N

0 Kudos
barragan_villanueva_
Valued Contributor I
2,195 Views

Hi,

>> The only thing I found.....

In your test there is the follwing line:

call getrf(A,ipiv)


But in that forum discussion you can find that getrf MKL FORTRAN 95 interface has three arguments.

0 Kudos
mike-s
Beginner
2,195 Views

Hi Victor,

thanks for the message. I should have mentioned that I tried it also with info, however according to the doc the info is optional.

( http://www.intel.com/software/products/mkl/docs/webhelp/lle/functn_getrf.html )

regards,

Mike

0 Kudos
mike-s
Beginner
2,195 Views

Hi C.S.,

thanks for trying it out. I tried the same, however still with the same error,

test.f90:(.text+0xf5): undefined reference to `dgetrf_mkl95_'
Can you check if you have an $MKL_ROOT/lib/em64t/libmkl_lapack95_lp64.so ?

I only have a static archive (.a) and wonder if this could be the cause.

Thanks for all the help,

Mike

attached my test program, I tried to compiled it with

ifort -I /opt/intel/Compiler/current/mkl/include/em64t/lp64/ -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 test.f90

and I also tried to replace the mkl_lapack95_lp64 with mkl_lapack

ifort -I /opt/intel/Compiler/current/mkl/include/em64t/lp64/ -lmkl_lapack -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 test.f90

Compiler output in both cases is

/tmp/ifortxkWohV.o: In function `MAIN__':
test.f90:(.text+0xf5): undefined reference to `dgetrf_mkl95_'

program test
use mkl95_lapack
use mkl95_precision
real*8 :: X(10,10)
integer :: info
integer,parameter :: n = 10
integer :: ipiv(n)
call getrf(X,ipiv,info)
end program

regards,

Mike

0 Kudos
barragan_villanueva_
Valued Contributor I
2,196 Views

Mike,

Please use-lmkl_lapack95_lp64 instead of -lmkl_lapack and source file before libraries.

So, correct link line is as follows:

ifort -I$MKLROOT/include/em64t/lp64 test.f90 -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5

0 Kudos
mike-s
Beginner
2,195 Views

Hi,

thanks a lot. The solution was to put the libs after the source file.

Regards,

Mike

0 Kudos
barragan_villanueva_
Valued Contributor I
2,195 Views

Mike,

BTW, link line was alsoa problemin that thead about LAPACK95 (see my reply #2)

Also, you are right some arguments can be optional.

0 Kudos
Reply