SharedLibLoadException
This exception is thrown when the shared library cannot be loaded. This indicates
that the library is not on the user's system, is not on the path, or perhaps has
a name that is different than expected. In otherwords, no library could be found
that matches the name returned by the sharedLibName property of this
exception.
SharedLibProcLoadException
This exception is thrown when a symbol cannot be loaded from a shared library.
This might indicate that the library is corrupt, or that it is a different version
than expected. In other words, the library exists on the system, but
no symbol that matches the name returned by the procName property of
this exception could be found. In some cases, it may be desirable to prevent this
exception from being thrown. You can learn how by reading about
Selective Symbol Loading.
InvalidSharedLibHandleException
This exception might be thrown when attempting to use a handle to a shared library
that has already been unloaded. The name of the unloaded library can be retrieved
by accessing the sharedLibName property of this exception.
void Derelict_SetMissingProcCallback(MissingProcCallback callback)
[typedef bool function(char[] libName, char[] procName) MissingProcCallback]
This function allows the client to set a callback that will be called when a
symbol cannot be found in a shared library. The name of the library will be passed
to the callback in the libName parameter and the name of the missing
symbol in the procName parameter. The client can use these parameters
to determine if Derelict should continue loading the shared library. If so, then
the callback should return true. If Derelict should abort loading and throw an exception,
the callback should return false. Note that the callback must be set before loading
the library(ies) you are interested in. You can read more about this feature in
the Selective Symbol Loading documentation.
SharedLib Derelict_LoadSharedLib(char[] libName)
Opens and returns a shared library handle of type SharedLib. This handle
is used by other functions in this module to manipulate the shared library. If
the library cannot be loaded, a SharedLibLoadException is thrown.
SharedLib Derelict_LoadSharedLib(char[][] libNames)
Given an array of shared library names, returns a handle to the first shared
library successfully loaded. This is intended for use on platforms where a single
library may have multiple possible names, such as Linux. The function iterates
the array until a successful load. If none of the names result in a successful
load, an exception is thrown for the last library name.
void* Derelict_GetProc(SharedLib lib, char[] procName)
Given a handle to a shared library and the name of a symbol, this function loads
the symbol from the shared library into memory and returns a pointer to it. This
can be used to load exported functions and variables from a shared library. If
the symbol cannot be found, this function first checks if a MissingProcCallback
has been set and, if so, calls it. Otherwise a SharedLibProcLoadException
is thrown. If the shared library referenced by the handle has already been
unloaded, an InvalidSharedLibHandleException is thrown.
void Derelict_UnloadSharedLib(SharedLib lib)
Unloads a shared library from memory. The library handle will no longer be valid.
Attempts to use it again could cause an InvalidSharedLibHandleException to
be thrown. However, if an invalid shared library handle is passed to this function,
no exception is thrown and the function is a no-op.