Main Content

C++ Shared Library Integration

Integrate packaged MATLAB® functions into C++ applications

MATLAB Compiler SDK™ provides two ways to deploy MATLAB functions within C++ applications:

  • Deploy to C++ Applications using MATLAB Data API (C++11) (since R2018a)

  • Deploy to C++ Applications using mwArray API (C++03)

Deploying MATLAB code to a C++ application using the MATLAB Data API is the newer and more modern of the two options and offers the following advantages:

  • Data copy operations are minimized.

  • You do not need to explicitly manage the life-cycle of the MATLAB Runtime instance and library of MATLAB functions in the archive since the C++ API provides a fail-safe way to terminate them.

  • The runtime instance can run either in-process or out-of-process with respect to the C++ application, and deployed MATLAB functions can be executed either synchronously or asynchronously.

  • Support for C++11 functionality, type-safety, and multi-thread-safety.

  • Support for strong types in MATLAB code.

  • Complex data is stored in the same interleaved format used by MATLAB internally since R2018a and by the C++ language. This eliminates the need for internal conversion.

MathWorks® recommends deploying to C++ using the MATLAB Data API. However, to select the right deployment option for your project, see Choose C++ Deployment Option.

MATLAB Runtime must be installed and set up on the machine running the C++ application. For details, see Download and Install MATLAB Runtime.

Categories