Main Content

CLibraryConfiguration

C++ library interface environment information

Since R2023a

Description

CLibraryConfiguration objects contain information about the settings and status of a MATLAB® interface to a C++ library. The environment information is persistent across different MATLAB sessions.

Creation

To create a CLibraryConfiguration object or change the settings, call clibConfiguration. The library is loaded when you call a command in the clib namespace. You cannot change the execution mode after MATLAB loads the library. To change how the library is loaded, restart MATLAB, and then call clibConfiguration.

Properties

expand all

This property is read-only.

Path to the interface library, returned as a string scalar.

This property is read-only.

Libraries used to build the interface, returned as a string scalar or string array.

This property is read-only.

Process status, returned as 1 if the library is loaded and 0 if the library is not loaded. By default, the library is not loaded. MATLAB loads the library when you call a command in the library namespace.

Execution mode indicating whether to load the C++ library interface in the same process as MATLAB or in an external process, specified as inprocess or outofprocess. To set the ExecutionMode property, call clibConfiguration with the ExecutionMode name-value argument.

This property is read-only.

MATLAB process ID, returned as a uint64 scalar. If the library is not loaded, then ProcessID is not displayed.

This property is read-only.

Process name in the registry, returned as a string scalar. The default name for an out-of-process host is MATLABCLibHost. If the library is not loaded, then ProcessName is not displayed.

Since R2025a

System environment variable names and values for the interface to the C++ library in out-of-process execution mode, specified as a dictionary object, where key-value pairs are defined as follows:

  • keys — The environment variable name or names, specified as a string scalar or string array.

    If keys contains an operating system path variable ("PATH", "LD_LIBRARY_PATH", or "DYLD_LIBRARY_PATH"), the function adds the specified path value to the existing path variable.

  • values — The environment variable value or values, specified as a string scalar or string array.

You can set or view environment variables in out-of-process mode only. To set the OutOfProcessEnvironmentVariables property, call clibConfiguration with the OutOfProcessEnvironmentVariables name-value argument.

Object Functions

unloadUnload process associated with C++ library

Examples

collapse all

Suppose that you built an interface libnameInterface.dll in C:\work on the MATLAB path for a C++ library libname.

Call function myfunc from the library.

clib.libname.myfunc

Display the library interface configuration.

configObj = clibConfiguration("libname")
configObj =

      CLibraryConfiguration for libname with properties:

        InterfaceLibraryPath: "C:\work"
                   Libraries: ""
                      Loaded: 1
               ExecutionMode: inprocess
                   ProcessID: 12345

Version History

Introduced in R2023a

expand all