Call C++ code from MATLAB?


I have some code which I need to code in C++ due to heavy reliance on templates. I want to call this code from MATLAB: basically, I need to pass some parameters to the C++ code, and have the C++ code return a matrix to MATLAB. I have heard this is possible with something called a MEX file which I am still looking into. However I am not sure what is supported in these MEX files. Is all of C++ (e.g. STL and Boost) supported? How difficult is it?

EDIT: I don't need any shared libraries, just header-only stuff like shared_ptr.

10/22/2009 2:07:07 PM

Have a look at the MEX-files Guide, especially Section 25–27 for C++. The basic STL/Boost data structures should work, but threading with Boost could be a problem.
cout will not work as expected in C++, mexPrintf has to be used instead.

10/22/2009 7:55:02 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow