+
+ if ( !handle )
+ {
+ wxString msg(_("Failed to load shared library '%s'"));
+
+#ifdef HAVE_DLERROR
+ wxChar *err = dlerror();
+ if( err )
+ {
+ failed = TRUE;
+ wxLogError( msg, err );
+ }
+#else
+ failed = TRUE;
+ wxLogSysError( msg, libname.c_str() );
+#endif
+ }
+
+ if ( success )
+ *success = !failed;
+
+ return handle;
+}
+
+
+/* static */
+void wxDllLoader::UnloadLibrary(wxDllType handle)
+{
+ wxDllClose(handle);
+}
+
+/* static */
+void *wxDllLoader::GetSymbol(wxDllType dllHandle, const wxString &name, bool *success)
+{
+ bool failed = FALSE;
+ void *symbol = 0;
+
+#if defined(__WXMAC__) && !defined(__UNIX__)
+ Ptr symAddress;
+ CFragSymbolClass symClass;
+ Str255 symName;
+
+#if TARGET_CARBON
+ c2pstrcpy( (StringPtr) symName, name );
+#else
+ strcpy( (char *) symName, name );
+ c2pstr( (char *) symName );
+#endif
+ if( FindSymbol( dllHandle, symName, &symAddress, &symClass ) == noErr )
+ symbol = (void *)symAddress;
+
+#elif defined(__WXPM__) || defined(__EMX__)
+ wxDllGetSymbol(dllHandle, symbol);
+
+#else
+ // mb_str() is necessary in Unicode build
+ symbol = wxDllGetSymbol(dllHandle, name.mb_str());
+
+#endif
+
+ if ( !symbol )
+ {
+ wxString msg(_("wxDllLoader failed to GetSymbol '%s'"));
+
+#ifdef HAVE_DLERROR
+ wxChar *err = dlerror();
+ if( err )
+ {
+ failed = TRUE;
+ wxLogError( msg, err );
+ }
+#else
+ failed = TRUE;
+ wxLogSysError(_("Couldn't find symbol '%s' in a dynamic library"),
+ name.c_str());
+#endif
+ }
+
+ if( success )
+ *success = !failed;
+
+ return symbol;