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

Problem with linking to the MKL library

thomas_krakow
Beginner
349 Views
Hello,

i've written the following code:

#include 
#include

#include "mkl.h"

int main(int argc, char *argv[])
{
MKL_INT n,incx=1,incy=1;
double x[2],y[2],res;

x[0]=1,x[1]=2;
y[0]=1;y[1]=3;

res = DDOT(&n, x, &incx, y, &incy);

return 0;
}

to compute the scalarproduct.
The compiling has completed succesfull with the gcc C compiler.
(I use Anjuta as IDE)

Now I tried to link tho main.o file with the following command

ld main.o -L$MKLPATH -lmkl_ia32 -lguide -lpthread

and I got the following error

ld: warning: cannot find entry symbol _start; defaulting to 00000000080486f0
main.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'

with
MKLPATH="/opt/intel/mkl/9.1.021/lib/32/"

I hope anyone can help me.

Thomas
0 Kudos
3 Replies
TimP
Honored Contributor III
349 Views
It looks as if you invoked g++ (inadvertently, perhaps by using a .C file type). If you have a reason for not simply using g++ rather than ld to drive the link, you will still need to find out which libraries g++ would have used (at a minimum, -lstdc++). You might find it easier to use lib_serial until you have a reason for using the threaded MKL.
0 Kudos
thomas_krakow
Beginner
349 Views
Hello tim18,

thank you for your reply.
Now I run the linker with

g++ main.o -L$MKLPATH -lpthread -lmkl -lmkl_ia32

and

MKLPATH="/opt/intel/mkl/9.1.021/lib_serial/32/"

I got the file a.out and run it, tehn I got the following error message

thomas@linux-q9zf:~/Projects/test/src> ./a.out
./a.out: error while loading shared libraries: libmkl.so: cannot open shared object file: No such file or directory

But I do have such file in the corresponding directory.

0 Kudos
thomas_krakow
Beginner
349 Views
Ok thank you I solved the problem, now it works.
I run the linker with the following command

thomas@linux-q9zf:~/Projects/test/src> g++ main.o -static -L$MKLPATH -lpthread -lmkl_ia32 -o exe
thomas@linux-q9zf:~/Projects/test/src> ./exe

0 Kudos
Reply