External Interfaces Reference |
Determine if external library is loaded
Syntax
Description
libisloaded('libname')
returns logical 1
(true
) if the shared library libname
is loaded and logical 0
(false
) otherwise.
libisloaded libname
is the command format for this function.
If you used an alias when initially loading the library, then you must use that alias for the libname
argument.
Example 1
Load the shrlibsample
library and check to see if the load was successful before calling one of its functions:
addpath([matlabroot '\extern\examples\shrlib']) loadlibrary shrlibsample.dll shrlibsample.h if libisloaded('shrlibsample') x = calllib('shrlibsample', 'addDoubleRef', 1.78, 5.42, 13.3) end
Since the library is successfully loaded, the call to addDoubleRef
works as expected and returns
Example 2
Load the same library, this time giving it an alias. If you use libisloaded
with the library name, shrlibsample
, it now returns false
. Since you loaded the library using an alias, all further references to the library must also use that alias:
addpath([matlabroot '\extern\examples\shrlib']) loadlibrary shrlibsample.dll shrlibsample.h alias lib libisloaded shrlibsample ans = 0 libisloaded lib ans = 1 unloadlibrary lib
See Also
loadlibrary
, libfunctions
, libfunctionsview
, libpointer
, libstruct
, calllib
, unloadlibrary
libfunctionsview | libpointer |
© 1994-2005 The MathWorks, Inc.