- p2cstr( myErrName );
- wxLogSysError( _("Failed to load shared library '%s' Error '%s'"),
- libname.c_str(),
- (char*)myErrName );
- m_handle = 0;
- }
-
-#elif defined(__WXPM__) || defined(__EMX__)
- char err[256] = "";
- DosLoadModule(err, sizeof(err), libname.c_str(), &m_handle);
-
-#elif defined(HAVE_DLOPEN)
-
-#ifdef __VMS
- m_handle = dlopen(libname.c_str(), 0); // The second parameter is ignored
-#else
- int rtldFlags = 0;
-
- if( flags & wxDL_LAZY )
- {
- wxASSERT_MSG( (flags & wxDL_NOW) == 0,
- _T("wxDL_LAZY and wxDL_NOW are mutually exclusive.") );
- rtldFlags |= RTLD_LAZY;
- }
- else if( flags & wxDL_NOW )
- {
- rtldFlags |= RTLD_NOW;
- }
- if( flags & wxDL_GLOBAL )
- {
-#ifdef __osf__
- wxLogDebug(_T("WARNING: RTLD_GLOBAL is not a supported on this platform."));
-#endif
- rtldFlags |= RTLD_GLOBAL;
- }
-
- m_handle = dlopen(libname.c_str(), rtldFlags);
-#endif // __VMS
-
-#elif defined(HAVE_SHL_LOAD)
- int shlFlags = 0;
-
- if( flags & wxDL_LAZY )
- {
- wxASSERT_MSG( (flags & wxDL_NOW) == 0,
- _T("wxDL_LAZY and wxDL_NOW are mutually exclusive.") );
- shlFlags |= BIND_DEFERRED;
- }
- else if( flags & wxDL_NOW )
- {
- shlFlags |= BIND_IMMEDIATE;
- }
- m_handle = shl_load(libname.c_str(), BIND_DEFERRED, 0);
-
-#elif defined(__DARWIN__)
- NSObjectFileImage ofile;
- int dyld_result = NSCreateObjectFileImageFromFile(libname.c_str(), &ofile);
-
- if (dyld_result != NSObjectFileImageSuccess)
- {
- TranslateError(libname.c_str(), OFImage, dyld_result);
- }
- else
- {
- // NSLinkModule will cause the run to abort on any link error's
- // not very friendly but the error recovery functionality is limited.
- m_handle = NSLinkModule(ofile, libname.c_str(), TRUE);
- }
-
-#elif defined(__WINDOWS__)
- m_handle = ::LoadLibrary(libname.c_str());
-
-#else
-#error "runtime shared lib support not implemented"
-#endif
-
- if ( m_handle == 0 )
- {
- wxString msg(_("Failed to load shared library '%s'"));
-#if defined(HAVE_DLERROR) && !defined(__EMX__)
- const wxChar *err = dlerror();
- if( err )
- wxLogError( msg, err );
-#else
- wxLogSysError( msg, libname.c_str() );
-#endif
- }
-
- return IsLoaded();
-}
-
-void wxDynamicLibrary::Unload()
-{
- if( IsLoaded() )
- {
-#if defined(__WXPM__) || defined(__EMX__)
- DosFreeModule( m_handle );
-#elif defined(HAVE_DLOPEN)
- dlclose( m_handle );
-#elif defined(HAVE_SHL_LOAD)
- shl_unload( m_handle );
-#elif defined(__WINDOWS__)
- ::FreeLibrary( m_handle );
-#elif defined(__WXMAC__)
- CloseConnection( &m_handle );
-#else
-#error "runtime shared lib support not implemented"
-#endif
- m_handle = 0;