+#if wxUSE_DYNLIB_CLASS
+
+#if defined(__WINDOWS__)
+ #include "wx/msw/private.h"
+#endif
+
+#include "wx/dynlib.h"
+#include "wx/filefn.h"
+#include "wx/intl.h"
+#include "wx/log.h"
+#include "wx/tokenzr.h"
+
+// ----------------------------------------------------------------------------
+// conditional compilation
+// ----------------------------------------------------------------------------
+
+#if defined(__WXPM__) || defined(__EMX__)
+# define INCL_DOS
+# include <os2.h>
+# define wxDllOpen(error, lib, handle) DosLoadModule(error, sizeof(error), lib, &handle)
+# define wxDllGetSymbol(handle, modaddr) DosQueryProcAddr(handle, 1L, NULL, (PFN*)modaddr)
+# define wxDllClose(handle) DosFreeModule(handle)
+#elif defined(HAVE_DLOPEN)
+ // note about dlopen() flags: we use RTLD_NOW to have more Windows-like
+ // behaviour (Win won't let you load a library with missing symbols) and
+ // RTLD_GLOBAL because it is needed sometimes and probably doesn't hurt
+ // otherwise. On True64-Unix RTLD_GLOBAL is not allowed and on VMS the
+ // second argument on dlopen is ignored.
+#ifdef __VMS
+# define wxDllOpen(lib) dlopen(lib.fn_str(), 0 )
+#elif defined( __osf__ )
+# define wxDllOpen(lib) dlopen(lib.fn_str(), RTLD_LAZY )
+#else
+# define wxDllOpen(lib) dlopen(lib.fn_str(), RTLD_LAZY | RTLD_GLOBAL)
+#endif
+#define wxDllGetSymbol(handle, name) dlsym(handle, name)
+# define wxDllClose dlclose
+#elif defined(HAVE_SHL_LOAD)
+# define wxDllOpen(lib) shl_load(lib.fn_str(), BIND_DEFERRED, 0)
+# define wxDllClose shl_unload
+
+ static inline void *wxDllGetSymbol(shl_t handle, const wxString& name)
+ {
+ void *sym;
+ if ( shl_findsym(&handle, name.mb_str(), TYPE_UNDEFINED, &sym) == 0 )
+ return sym;
+ else
+ return (void *)0;
+ }
+#elif defined(__DARWIN__)
+/* Porting notes:
+ * The dlopen port is a port from dl_next.xs by Anno Siegel.
+ * dl_next.xs is itself a port from dl_dlopen.xs by Paul Marquess.
+ * The method used here is just to supply the sun style dlopen etc.
+ * functions in terms of Darwin NS*.
+ */
+void *dlopen(const char *path, int mode /* mode is ignored */);
+void *dlsym(void *handle, const char *symbol);
+int dlclose(void *handle);
+const char *dlerror(void);
+
+# define wxDllOpen(lib) dlopen(lib.fn_str(), 0)
+# define wxDllGetSymbol(handle, name) dlsym(handle, name)
+# define wxDllClose dlclose
+#elif defined(__WINDOWS__)
+ // using LoadLibraryEx under Win32 to avoid name clash with LoadLibrary
+# ifdef __WIN32__
+#ifdef _UNICODE
+# define wxDllOpen(lib) ::LoadLibraryExW(lib, 0, 0)
+#else
+# define wxDllOpen(lib) ::LoadLibraryExA(lib, 0, 0)