Skip to Main Content Skip to Search
Product Documentation

libisloaded - Determine if shared library is loaded

Syntax

libisloaded('libname')
libisloaded libname

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.

Examples

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 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

x =
   20.5000

unloadlibrary shrlibsample

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 shrlibsample.h alias lib

libisloaded shrlibsample
ans =
     0

libisloaded lib
ans =
     1

unloadlibrary lib

See Also

loadlibrary | unloadlibrary

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS