In principle you can link mex files to arbitrary external dlls/shared libraries, using the -l
and -L
options.
E.g., as taken from http://www.mathworks.de/de/help/matlab/ref/mex.html:
mex('-largeArrayDims',['-L' lapackpath],'-llibmwlapack','matrixDivide.c')
Simply adjust -llibmwlapack
and lapackpath
to your needs.