External Interfaces |
Loading and Unloading the Library
To give MATLAB access to external functions in a shared library, you must first load the library into memory. Once loaded, you can request information about any of the functions in the library and call them directly from MATLAB. When the library is no longer needed, you will need to unload it from memory to conserve memory usage.
Loading the Library
To load a shared library into MATLAB, use the loadlibrary
function. The syntax for loadlibrary
is
where shrlib
is the filename for the .dll
shared library file, and hfile
is the filename for the header file that contains the function prototypes. See the reference page for loadlibrary
for variations in the syntax that you can use.
Note
The header file provides signatures for the functions in the library and is a required argument for loadlibrary .
|
As an example, you can use loadlibrary
to load the libmx
library that defines the MATLAB mx
routines. The first statement below forms the directory specification for the matrix.h
header file for the mx
routines. The second loads the library from libmx.dll
, also specifying the header file:
There are also several optional arguments that you can use with loadlibrary
. See the loadlibrary
reference page for more information.
Unloading the Library
To unload the library and free up the memory that it occupied, use the unloadlibrary
function. For example,
Overview | Getting Information About the Library |
© 1994-2005 The MathWorks, Inc.