Call Functions in C++ Shared Library
Set MATLAB and Run-Time Paths
The publisher of your MATLAB® interface to a C++ library provides you with instructions for installing the interface file and any dependent library files, if required. The publisher might give you dependent library files or ask you to install libraries from an external source.
MATLAB looks for the interface file on the MATLAB path and the dependent library files on the system path or run-time search path (rpath). If the publisher gives you dependent library files, you can put them in the same folder as the interface file. Alternatively, to add them to the system path, see Set Run-Time Library Path for C++ Interface. For information about locating dependent libraries, see Missing or Incorrectly Installed Run-Time Libraries.
Call addpath
on the interface folder.
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";
clib.memberName
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, ...)