clibConfiguration - Change execution mode of C++ library interface - MATLAB (original) (raw)

Main Content

Change execution mode of C++ library interface

Since R2023a

Syntax

Description

MATLAB® can load an interface to a C++ library either in-process or out-of-process. UseclibConfiguration to change the execution mode.

libraryconfig = clibConfiguration([libname](#mw%5F2aeb9814-8ec4-4313-900d-cf652925aa6b),[ExecutionMode](#mw%5Fae0fd56e-f708-453c-b643-e07545ab2761)=ExecutionMode) changes the execution mode of the library. Use ExecutionMode to indicate whether MATLAB loads the C++ library interface in-process or out-of-process. The setting is persistent across different MATLAB sessions.

MATLAB loads the library when you call your library using the syntaxclib._`libraryName`_ followed by the library construct type. If the ExecutionMode is "inprocess", then you cannot change the interface to the library and reload it into MATLAB. To enable making changes to the interface and reloading in the same session, restart MATLAB, and then callclibConfiguration(ExecutionMode="outofprocess").

example

Examples

collapse all

Display Configuration for Library

Suppose that you built an interfacelibnameInterface.dll in C:\work which is on the MATLAB path for a library libname.lib. Assuming that the library is not loaded, type:

configObj = clibConfiguration("libname")

configObj = CLibraryConfiguration for libname with properties: InterfaceLibraryPath: "C:\work" Libraries: "libname.lib" Loaded: 0 ExecutionMode: inprocess

Change Execution Mode

Suppose that you built an interfacemylibInterface.dll in C:\work which is on MATLAB path for a library mylib.lib. To change the execution mode if the library is not loaded, type:

configObj = clibConfiguration("mylib",ExecutionMode="outofprocess")

configObj = CLibraryConfiguration for mylib with properties: InterfaceLibraryPath: "C:\work" Libraries: "mylib.lib" Loaded: 0 ExecutionMode: outofprocess

Input Arguments

collapse all

libname — Name of interface to C++ library

string | character vector

Name of the interface to a C++ library, specified as a string or a character vector.

ExecutionMode — Execution mode

"inprocess" (default) | "outofprocess"

Execution mode indicating whether to load the library in the same process as MATLAB, specified as "inprocess" or"outofprocess". The default "inprocess" loads the library in the MATLAB process. Use this mode for performance-critical use cases. Set this mode after you develop and test the interface.

Select "outofprocess" for:

Version History

Introduced in R2023a