Main Content

Call Functions in C++ Shared Library

Set Path

Put the MATLAB® interface file on the MATLAB path using the addpath function.

The C++ shared library file and its dependencies, if any, must be on your system path or run-time search path (rpath). For more information, see Set Run-Time Library Path for C++ Interface.

Display Help

The MATLAB help and doc functions provide help for members of the library. For example, to display help for function funcname in library libname, type:

help clib.libname.funcname

Call Function

To call a function in a C++ library, use the MATLAB clib package. MATLAB automatically loads the library when you type:

memberName = "fully-qualified-class-member";

After MATLAB loads the library, you can use tab completion to view the members of the clib package.

For example, to call function funcname in library libname, type the following statement. funcname defines the input arguments arg1, arg2, ... and the output argument retVal.

retVal = clib.libname.funcname(arg1, arg2, ...)

Related Topics