Quantcast
Channel: Intel® Software - Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 3005

mex command for mkl linking on linux

$
0
0

Hi

I am trying to compile a c code through mex function in matlab. I was able to do so on a windows machine, but not on a linux one. The mkl line advisor gave me the following:

Link line:

 -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_intel_thread.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -liomp5 -lpthread -lm -ldl

Compiler options:

 -DMKL_ILP64 -m64 -I${MKLROOT}/include

I tried many things, but nothing helped. Followingsome references in the net, i used the following makefile:

#!/bin/make
 
BINARY = mexDAFEM.mexa64
 
MATLAB = /usr/local/packages/matlabR2016a
MKLROOT = /u/c/radhiali/intel/mkl
MKLLIB = $(MKLROOT)/lib/intel64
 
CC = gcc
OPTS = -DMATLAB_MEX_FILE -DMKL_ILP64 -fPIC -fno-omit-frame-pointer -DMX_COMPAT_32 -O3 -D_GNU_SOURCE
SRC = mexDAFEM.c
OBJS = $(SRC:.c=.o)
 
INC = -I$(MATLAB)/extern/include -I$(MATLAB)/simulink/include -I$(MKLROOT)/include
LIBS = -shared -Wl,--version-script,$(MATLAB)/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined
LIBS += -Wl,-rpath-link,$(MATLAB)/bin/glnxa64 -L$(MATLAB)/bin/glnxa64 -lmx -lmex -lmat
LIBS += -Wl,--start-group $(MKLLIB)/libmkl_intel_ilp64.a $(MKLLIB)/libmkl_sequential.a $(MKLLIB)/libmkl_core.a -Wl,--end-group
LIBS += -lpthread -lm -ldl
 
.SUFFIXES: .c .o
 
.c.o:
    $(CC) $(OPTS) $(INC) -c $< -o $@
 
$(BINARY): $(OBJS)
    $(CC) $(OBJS) $(OPTS) -o $(BINARY) $(LIBS)
    @echo Binary created!!

 

It compiled, but the matlab shows a system error, saying it encountered an internal problem and needs to close.

Please advise as I am at my wit's end with this problem. Thank you in advance for making the time.

 

Regards

Ali Radhi

 

Thread Topic: 

How-To

Viewing all articles
Browse latest Browse all 3005


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>