+// Add the weak linking attribute to dlopen's declaration
+extern void * dlopen(const char * __path, int __mode) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+// For all of these methods we test dlopen since all of the dl functions we use were added
+// to OS X at the same time. This also ensures we don't dlopen with the real function then
+// dlclose with the internal implementation.
+
+static inline void *wx_dlopen(const char *__path, int __mode)
+{
+#ifdef HAVE_DLOPEN
+ if(&dlopen != NULL)
+ return dlopen(__path, __mode);
+ else
+#endif
+ return wx_darwin_dlopen(__path, __mode);
+}
+
+static inline int wx_dlclose(void *__handle)
+{
+#ifdef HAVE_DLOPEN
+ if(&dlopen != NULL)
+ return dlclose(__handle);
+ else
+#endif
+ return wx_darwin_dlclose(__handle);
+}
+
+static inline const char *wx_dlerror()
+{
+#ifdef HAVE_DLOPEN
+ if(&dlopen != NULL)
+ return dlerror();
+ else
+#endif
+ return wx_darwin_dlerror();
+}
+
+static inline void *wx_dlsym(void *__handle, const char *__symbol)
+{
+#ifdef HAVE_DLOPEN
+ if(&dlopen != NULL)
+ return dlsym(__handle, __symbol);
+ else
+#endif
+ return wx_darwin_dlsym(__handle, __symbol);
+}
+
+#else // __DARWIN__/!__DARWIN__
+
+// Use preprocessor definitions for non-Darwin or OS X >= 10.3
+#define wx_dlopen(__path,__mode) dlopen(__path,__mode)
+#define wx_dlclose(__handle) dlclose(__handle)
+#define wx_dlerror() dlerror()
+#define wx_dlsym(__handle,__symbol) dlsym(__handle,__symbol)
+