Call C++ from MATLAB
If you have a C or C++ shared library that exports functionality that can be called from another application, then you can use those classes and functions directly in MATLAB. To get started, you must first build an interface to the library to use to call the functionality in MATLAB. Someone who creates this interface is called a publisher. You can package the interface and share it with a MATLAB end user.
To call the library functionality in MATLAB, see Use Prebuilt MATLAB Interface to C++ Library.
To call functions in a C shared library from MATLAB R2021b and earlier, use the calllib
function. For information, see Call C from MATLAB. This feature
works best with C-only libraries.
To create MATLAB functions written in C or C++, see Write C++ Functions Callable from MATLAB (MEX Files) or Write C Functions Callable from MATLAB (MEX Files).
Publish Interface to Library Defined by These Files
Categories
- Build MATLAB Interface to C++ Library
To create a MATLAB interface to a C++ library, use the MATLABclibgen
namespace
- Use Prebuilt MATLAB Interface to C++ Library
To call a function in a C++ library, use the MATLABclib
namespace