Load a shared library, returning an opaque handle.
The extension given by the constant
.dylib) can be omitted from the
libfile string, as it is automatically appended if needed. If
libfile is not an absolute path name, then the paths in the array
DL_LOAD_PATH are searched for
libfile, followed by the system load path.
The optional flags argument is a bitwise-or of zero or more of
RTLD_FIRST. These are converted to the corresponding flags of the POSIX (and/or GNU libc and/or MacOS) dlopen command, if possible, or are ignored if the specified functionality is not available on the current platform. The default flags are platform specific. On MacOS the default
dlopen flags are
RTLD_LAZY|RTLD_DEEPBIND|RTLD_GLOBAL while on other platforms the defaults are
RTLD_LAZY|RTLD_DEEPBIND|RTLD_LOCAL. An important usage of these flags is to specify non default behavior for when the dynamic library loader binds library references to exported symbols and if the bound references are put into process local or global scope. For instance
RTLD_LAZY|RTLD_DEEPBIND|RTLD_GLOBAL allows the library’s symbols to be available for usage in other shared libraries, addressing situations where there are dependencies between shared libraries.