Loading and unloading shared libraries is done through a global object declared in each Derelict package. The object is named exactly as the package in which it is declared. The loader interface defines load methods that can be used to load a shared library into memory, and an unload method that can be used to remove the shared library from memory.
As an example, if you were using DerelictSDL, you would use the following syntax to load the SDL shared library:
DerelictSDL.load();From that point onward you would be able to use all SDL functions normally.
The load method accepts an optional shared library name string parameter that will overload the default search mechanism. For example, on Windows DerelictAL attempts to load "openal32.dll" by default. Some systems have audio drivers that provide a hardware accelerated version of OpenAL, some do not. You may want to ship the OpenAL dll with your app, but renamed to something like "myopenal.dll", or perhaps with the same name but in a subdirectory of the application directory ("al/openal32.dll"). If the DerelictAL.load() fails, then you can call DerelictAL.load("myopenal.dll") instead. This is important because Windows (and other OSes) will look in the application's directory for a given shared library before looking in system directories. If you were to drop openal32.dll in your application's directory, that version would be loaded every time and any hardware accelerated version in the system directories would be ignored. This technique can be used for every Derelict package, not just DerelictAL.
Sometimes, loads fail. There are several root causes for this, the end result being either that the system couldn't find the shared library or that one of the functions Derelict expected to find in the library wasn't there. In either case, the load method will throw an exception. You can read more about Derelict exceptions in the documentation for DerelictUtil. You can also learn how to bypass some exceptions in the documentation on Derelict's selective loading system.
DerelictSDL.unload();In normal usage of Derelict, you do not need to unload any of the shared libraries. Derelict will do this for you automatically. The unload method is provided as a convenience for those who want to implement hot swapping or want to free up memory if a library is no longer needed during execution.