Link Matlab and C ++ code using the Eigen library

advertisements

I am trying to make some C++ code that uses the Eigen library callable from Matlab. I can't seem to find any pointers on how to do that with Matlab.

Can you compile with matlab making a mex file that uses these kind of libraries? I know you can call MathWorks libraries but that would mean rewriting the code.


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.