- wxASSERT_MSG(m_handle == 0, _T("Library already loaded."));
-
- if( !(flags & wxDL_VERBATIM) )
- libname += GetDllExt();
-
-#if defined(__WXMAC__) && !defined(__UNIX__)
- FSSpec myFSSpec;
- Ptr myMainAddr;
- Str255 myErrName;
-
- wxMacFilename2FSSpec( libname , &myFSSpec );
-
- if( GetDiskFragment( &myFSSpec,
- 0,
- kCFragGoesToEOF,
- "\p",
- kPrivateCFragCopy,
- &m_handle,
- &myMainAddr,
- myErrName ) != noErr )
- {
- 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());