Main Content

Convert C++ Engine Application to MATLAB Compiler SDK Application

You can deploy an engine application by modifying your code to use the MATLAB® Compiler SDK™ API. For information about this API, see C++ MATLAB Data API Shared Library Integration (MATLAB Compiler SDK). Make these modifications to use the equivalent Compiler SDK C++ values:

  • Header file

    MatlabCppSharedLib.hpp

  • Namespace

    matlab::cpplib

  • Class name

    matlab::cpplib::MATLABApplication

  • Compiler SDK requires the path of CTF (library archive file) to be set. For example:

    const std::u16string U16STR_CTF_NAME = u"libtriangle.ctf";
    auto lib = mc::initMatlabLibrary(app, U16STR_CTF_NAME);

Applications to Call Sierpinski Function

This example is an engine application that calls a MATLAB function sierpinski which calculates the points in Sierpinski's triangle. The example shows how to modify the engine code to run with MATLAB Compiler SDK.

If you have Compiler SDK, then you can use the graphical Sierpinski function sierpinski.m in the matlabroot/extern/examples/compilersdk/c_cpp/triangle folder.

Copy this code into the file triangleEngine.cpp.

 Engine Application triangleEngine.cpp

Modify the code to use the equivalent Compiler SDK C++ values.

If you copy the following code into triangleSDK.cpp and compare the file with triangleEngine.cpp, then you can see other modifications relevant to calling the Sierpinski function.

 Corresponding Deployed Application triangleSDK.cpp

Related Topics