About Matlab C++ Math Library

10 views (last 30 days)
Oktay Arslan
Oktay Arslan on 23 Apr 2012

Hello,

I want to develop a standalone C++ application which uses Matlab C++ Math library. Simply, I want to implement a nonlinear dynamical system and needs Matlab C++ functions to integrate it for simulation.

I've found the following link which mentions about "MATLAB C++ Math Library" and it says include the following header

#include matlab.hpp

I use Matlab R2011a and couldn't find this header file under $MatlabHome$/extern/include folder. Is "matlab.hpp" obsolete? How can I find the header file which includes information about "mwArray" class?

Regards.

Answers (2)

Kaustubha Govind
Kaustubha Govind on 24 Apr 2012
AFAIK, the MATLAB C++ Math Library was retired around R14. You now need to use the MATLAB Compiler product to deploy MATLAB code onto a machine that does not have MATLAB installed. See R14 Release Notes:
"MATLAB Compiler 4 uses the new MATLAB Compiler Runtime (MCR), which is a standalone set of shared libraries that enable the execution of compiled MATLAB files, instead of the MATLAB C/C++ Math and Graphics Libraries. The MCR provides complete support for all features of the MATLAB language."
If you only want to run MATLAB code from a C++ application running on a machine where MATLAB is installed, consider using the MATLAB Engine nterface.

Oktay Arslan
Oktay Arslan on 24 Apr 2012
Hi Kaustubha,
Well, I don't want to write any Matlab code (.m files) then convert them to a C/C++ code using code generator or run a Matlab engine and call some Matlab function to do something in Matlab, then get them back in my C++ application. Either ways are not fast and convenient for what I am doing.
I am trying to write a stand-alone C++ application which needs information of trajectories of a nonlinear system to process, so I need to integrate a set of nonlinear differential equation in my main code.
I wrote a simple numeric integration routine (Euler method) using Octave C++ API, but it seems numerical errors sum up so my solution is not a good approximation anymore. I am trying to use ode45 directly in a C++ application. I don't know if this is possible.
So far, I've included the "mclcppclass.h" file under $/extern/include folder to use mwArray class and but couldn't find the related libraries. There are some files under $/extern/include/lib/glnxa64 folder, but compiler still gives error even if I include them as libraries.
fexport.map mexFunction.map mexLibrary.map
Thanks,
  1 Comment
Kaustubha Govind
Kaustubha Govind on 25 Apr 2012
Oktay: Do you need this task to be fast in terms of development time or performance? For performance, I don't think there is a more efficient way of calling the ODE functions outside of MATLAB other than calling into MATLAB Engine or using MATLAB Compiler (since the ODE solvers are not supported for code generation). If you mean fast in terms of development time, I'm not sure that using the (erstwhile) MATLAB C++ Math Library is much different from using the MATLAB Engine interface.
About the compiler errors regarding the libraries - perhaps you are attempting to build a 32-bit binary from your C++ application? Visual Studio for example is configured to produce 32-bit binaries by default, so it can't link against the 64-bit MATLAB libraries. You need to configure your project for an x64 target.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!