Main Content

C Shared Library Integration

Integrate packaged MATLAB® functions into C applications

MATLAB Compiler SDK™ enables you to create C shared libraries from MATLAB functions.

Shared libraries that use the mxArray API have an interface that uses C-style functions to initialize the MATLAB Runtime, load the packaged MATLAB functions into the MATLAB Runtime, and manage data that is passed between the C code and the MATLAB Runtime. For an example, see Create a C Shared Library with MATLAB Code.

Functions C shared library (Since R2021a) for building C shared libraries (Since R2021a) build results object (Since R2020b)
mbuildCompile and link source files against MATLAB generated shared libraries


mclmcrInitializeInitialize 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
mclRunMainMechanism for creating identical wrapper code across all platforms
mclIsMCRInitializedDetermine if MATLAB Runtime has been properly initialized
mclWaitForFiguresToDieEnable deployed applications to process graphics events so that figure windows remain displayed
mclGetLastErrorMessageLast error message from unsuccessful library initialization or MATLAB function call
mclGetLogFileNameRetrieve name of log file used by MATLAB Runtime
mclIsJVMEnabledDetermine if MATLAB Runtime was started with instance of Java Virtual Machine (JVM)
mclIsNoDisplaySetDetermine if -nodisplay mode is enabled


Create and Implement a C Shared Library

Integrate a C Shared Library with a C Driver Application

Troubleshooting C Shared Libraries