This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

C/C++ Shared Library Integration

Integrate compiled MATLAB® functions into C or C++ applications

Integrating compiled MATLAB functions into a C or C++ application requires you to use a combination of APIs. MATLAB Compiler SDK™ uses APIs to initialize the MATLAB Runtime, load the compiled MATLAB functions into the MATLAB Runtime, and manage data that is passed between the C or C++ code and the MATLAB Runtime. The compiler generates some of the APIs based on the signatures of the compiled functions. MATLAB Runtime provides other APIs that are consistent for all applications.

To integrate MATLAB functions with your application code see Call a Shared Library.


mbuildCompile and link source files against MATLAB generated shared libraries


mclmcrInitializeInitializes the MATLAB Runtime proxy library
mclInitializeApplicationSet up application state shared by all MATLAB Runtime instances created in current process
mclTerminateApplicationClose MATLAB Runtime-internal application state
<library>Initialize[WithHandlers]Initialize MATLAB Runtime instance associated with library
<library>TerminateFree all resources allocated by MATLAB Runtime instance associated with library
mwArrayClass used to pass input/output arguments to C++ functions generated by MATLAB Compiler SDK
mwExceptionException type used by the mwArray API and the C++ interface functions
mwStringString class used by the mwArray API to pass string data as output from certain methods
mclRunMainMechanism for creating identical wrapper code across all platforms
mclIsMCRInitializedDetermine if MATLAB Runtime has been properly initialized
mclWaitForFiguresToDieEnable deployed applications to process graphics events, enabling figure windows to remain displayed
mclGetLastErrorMessageLast error message from unsuccessful function call
mclGetLogFileNameRetrieve name of log file used by MATLAB Runtime
mclIsJVMEnabledDetermine if MATLAB Runtime was launched with instance of Java Virtual Machine (JVM)
mclIsNoDisplaySetDetermine if -nodisplay mode is enabled

Examples and How To

Integrate a C/C++ Shared Library into an Application

This example shows how to call a C++ shared library built with MATLAB Compiler SDK from a C++ application.

Call a Shared Library

To use a MATLAB Compiler SDK generated shared library in your application:

Integrate C Shared Libraries

Creating and distributing C shared libraries

Integrate C++ Shared Libraries

Creating and distributing C++ shared libraries

Call MATLAB Compiler SDK API Functions from C/C++

Using MATLAB Compiler SDK generated interface functions

Use Multiple Shared Libraries in Single Application

Use multple generated shared libraries in a single C/C++ application

Configure the mbuild Options File

Configuring a supported C/C++ compiler to work with MATLAB Compiler SDK

Call COM Objects in Visual C++ Programs

How to integrate a COM object into a Visual C++® program


MATLAB Runtime Path Settings for Development and Testing

Path settings for machines where you want to develop and test applications that contain compiled MATLAB code

Memory Management and Cleanup

Recommendations on memory management

MATLAB Runtime Startup Options

Set MATLAB Runtime options, such as -nojvm, -nodisplay, or -logfile

Understand the mclmcrrt Proxy Layer

All application and software components generated by MATLAB Compiler™ and MATLAB Compiler SDK need to link against only one MATLAB library, mclmcrrt.

MATLAB Runtime Component Cache and Deployable Archive Embedding

How to override the default archive embedding behavior and how to use MATLAB Runtime component cache

Was this topic helpful?