Main Content

Deploy to C++ Applications Using MATLAB Data API (C++11)

Integrate packaged MATLAB® functions into C++ applications using the MATLAB Data API

In this approach, you use functionality in MATLAB Compiler SDK™ to generate a code archive (.ctf file) containing MATLAB functions, along with a header (.hpp file) that establishes a mapping between MATLAB and C++ data types. Integrate these within your C++ application.

Use MATLAB Compiler SDK API for C++ as an interface between the C++ application and the code archive containing the deployed MATLAB functions. Use the MATLAB Data API to handle data exchange between the C++ application and deployed MATLAB functions. For details on data exchange, see MATLAB Data API for C++.

To ensure that this is the right approach for you, see Choosing C++ Deployment Option.

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

Functions

compiler.build.cppSharedLibraryCreate C++ shared library (Since R2021a)
compiler.build.CppSharedLibraryOptionsOptions for building C++ shared libraries (Since R2021a)
mbuildCompile and link source files against MATLAB generated shared libraries
mccCompile MATLAB functions for deployment

C/C++ API

matlab::cpplib::initMATLABApplicationStart the MATLAB Runtime and initialize its application state
matlab::cpplib::runMainExecute a function with its input arguments within the main function
matlab::cpplib::convertUTF8StringToUTF16StringConvert UTF-8 string to UTF-16 string
matlab::cpplib::convertUTF16StringToUTF8StringConvert UTF-16 string to UTF-8 string
matlab::cpplib::initMATLABLibraryInitialize a library of MATLAB functions packaged in a deployable archive file
matlab::cpplib::initMATLABLibraryAsyncInitialize a library of MATLAB function asynchronously
matlab::cpplib::MATLABLibrary::fevalExecute a MATLAB function from a deployable archive
matlab::cpplib::MATLABLibrary::fevalAsyncExecute a MATLAB function from a deployable archive asynchronously
matlab::cpplib::MATLABLibrary::waitForFiguresToCloseWait for all figures to close

Topics

Requirements

Create and Integrate

Data Type Mapping and Sample Generation

More Code Samples

Maintenance