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 themxArrayAPI have an interface that uses C-style functions to initialize theMATLAB Runtime, load the packaged MATLAB functions into theMATLAB Runtime, and manage data that is passed between the C code and theMATLAB Runtime. For an example, seeImplement a C Shared Library with a Driver Application.

Functions

compiler.build.cSharedLibrary Create C shared library
compiler.build.CSharedLibraryOptions Options for building C shared libraries
mbuild Compile and link source files againstMATLABgenerated shared libraries

C API

mclmcrInitialize Initialize theMATLABRuntimeproxy library
mclInitializeApplication Set up application state shared by allMATLABRuntimeinstances created in current process
mclTerminateApplication CloseMATLABRuntime-internal application state
Initialize[WithHandlers] InitializeMATLABRuntimeinstance associated withlibrary
Terminate Free all resources allocated byMATLABRuntimeinstance associated withlibrary
mclRunMain Mechanism for creating identical wrapper code across all platforms
mclIsMCRInitialized Determine ifMATLABRuntimehas been properly initialized
mclWaitForFiguresToDie Enable deployed applications to process graphics events, enabling figure windows to remain displayed
mclGetLastErrorMessage Last error message from unsuccessful function call
mclGetLogFileName Retrieve name of log file used byMATLABRuntime
mclIsJVMEnabled Determine ifMATLABRuntimewas started with instance ofJavaVirtual Machine (JVM)
mclIsNoDisplaySet Determine if-nodisplaymode is enabled

Topics

Create and Implement a C Shared Library

Create a C Shared Library with MATLAB Code

Learn how to create a C shared library.

Create C/C++ Shared Libraries from Command Line

Use the command-line compiler to create C/C++ shared libraries.

Implement a C Shared Library with a Driver Application

Call a C shared library built withMATLAB Compiler SDKfrom a C driver application.

Integrate a C Shared Library with a C Driver Application

Call a C Shared Library

Use one or moreMATLAB Compiler SDKgenerated C shared libraries in your C application.

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

UseMATLAB Compiler SDKAPI functions for C/C++ to assimilate shared libraries in driver code.

Compile and Test a MATLAB Generated C Shared Library

Compile the C driver code and shared libraries, and test the C application.

Use Multiple Shared Libraries in Single Application

Use multiple generated shared libraries in a single C/C++ application.

Mac OS X

Write Applications for macOS

Write deployable C++ applications specifically formacOS.

MATLABRuntime

Install and Configure MATLAB Runtime

Install, configure, and uninstallMATLAB Runtime.

Set MATLAB Runtime Path for Deployment

Define paths for machines where you want to run applications generated withMATLAB Compiler™orMATLAB Compiler SDK.

MATLAB Runtime Startup Options

SetMATLAB Runtimeoptions, such as-nojvm,-nodisplay, or-logfile.

MATLAB Runtime Component Cache and Deployable Archive Embedding

Override the default archive embedding behavior, and useMATLAB Runtimecomponent cache.