Reputation: 231
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.
Upvotes: 1
Views: 1837
Reputation: 231
In the case of the Eigen c++ library it suffices to copy the Eigen folder from the library to the folder your c++ files are in. The command you than need to use is mex -I./ yourfile.cpp
Upvotes: 1
Reputation: 53
so you didn't attache any source, i try to give some general advice.
You can have a look at: http://www.mathworks.de/de/help/matlab/ref/mex.html
and in your matlab release should be some examples: matlabroot/toolbox/simulink/fixedandfloat/fxpdemos/
once i had to do that for some c++ code, calling a filter function, written in c++, in matlab.
Upvotes: 0
Reputation: 9696
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.
Upvotes: 0