A shared library is a collection of functions dynamically loaded by an application at run time. This MATLAB® interface supports libraries containing functions defined in C header files. To call functions in C++ libraries, see the interface described in C++ Libraries.
MATLAB supports dynamic linking on all supported platforms.
|Platform||Shared Library||File Extension|
|dynamic link library file|
|shared object file|
|dynamic shared library|
A shared library needs a header file, which provides signatures for the functions in the library. A function signature, or prototype, establishes the name of the function and the number and types of its parameters. Specify the full path of the shared library and its header file.
You need an installed MATLAB-supported C compiler. For an up-to-date list of supported compilers, see Supported and Compatible Compilers.
MATLAB accesses C routines built into external, shared libraries through a command-line interface. This interface lets you load an external library into MATLAB memory and access functions in the library. Although types differ between the two language environments, usually you can pass types to the C functions without converting. MATLAB converts for you.
Details about using a shared library are in these topics.
If the library function passes arguments, you need to determine the data type passed to and from the function. For information about data, see these topics.
When you are finished working with the shared library, it is important to unload the library to free memory.