Load and Unload C Shared Library
Note
To use C libraries with MATLAB® R2022a or later, see Call C++ from MATLAB.
To give MATLAB access to functions in a C shared library, first load the library into memory. After you load the library, you can request information about library functions and call them directly from the MATLAB command line.
To load a shared library into MATLAB, use the loadlibrary
function. The most common
syntax is:
loadlibrary('shrlib','hfile')
where shrlib
is the shared library file name, and
hfile
is the name of the header file containing the
function prototypes.
Note
The header file provides signatures for the functions in the library and is a
required argument for loadlibrary
.
When you are finished working with the shared library, it is important to unload the library to free memory.