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

runtime error when Matlab mex file calling MKL

Kai_S_
Beginner
737 Views

Dear all,

I am working on an AMD64 machine running Linux, Matlab 2008b and MKL 10.2.4.

I wrote a piece of cpp code calling MKL functions. I have compiled it successfully in Matlab using gnu C compiler.My compile script looks like this.

mex -v -I"/home/tom/intel/mkl/10.2.4.032/include" quad_mkl.cpp -L"/home/tom/intel/mkl/10.2.4.032/lib/em64t" -lmkl_solver_ilp64 -lmkl_intel_ilp64 -lmkl_gnu_thread -lmkl_core

But I got runtime error like the following.

[s2] = quad_mkl(x1, x2, lx2, w, lam, a, u, sigsq, d, t)
??? Invalid MEX-file '/home/tom/intel/mkl/10.2.4.032/lib/em64t/quad_mkl.mexa64':
libmkl_intel_ilp64.so: cannot open shared object file: No such file or directory.

This happens even when I run it in the same folder with libmkl_intel_ilp64.so. Can anybody here give me some help? Thanks!

0 Kudos
4 Replies
Vladimir_Koldakov__I
New Contributor III
737 Views

Hello,

As you use ilp64 libraries, you should use -DMKL_ILP64 command line option. See user guide:

Compiling for ILP64: icc -DMKL_ILP64 -I/include

Of course, you may define MKL_ILP64 in your C/C++ code.

Thanks,
Vladimir

0 Kudos
Kai_S_
Beginner
737 Views
Actually, I am not sure if I shall use LP64 or ILP64. I am using it in Matlab mex. All I know is that my Matlab is 64-bit version. Which one shall I use?
0 Kudos
Gennady_F_Intel
Moderator
737 Views

well, please try to replace-lmkl_intel_ilp64 by the-lmkl_intel_lp64

and your linking line will looks like:

mex -v -I"/home/tom/intel/mkl/10.2.4.032/include" quad_mkl.cpp -L"/home/tom/intel/mkl/10.2.4.032/lib/em64t" -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core

and try again..

0 Kudos
Kai_S_
Beginner
737 Views

I have changed the linking line as you said, but it gave me the same runtime error.

[s2] = quad_mkl(x1, x2, lx2, w, lam, a, u, sigsq, d, t)

??? Invalid MEX-file '/home/tom/intel/mkl/10.2.4.032/lib/em64t/quad_mkl.mexa64':

libmkl_intel_lp64.so: cannot open shared object file: No such file or directory.

0 Kudos
Reply