#endif
#include "wx/filename.h" // for SplitPath()
+#include "wx/strconv.h"
#include "wx/dynload.h"
#include "wx/module.h"
}
}
+ // different ways to load a shared library
+ //
+ // FIXME: should go to the platform-specific files!
#if defined(__WXMAC__) && !defined(__DARWIN__)
FSSpec myFSSpec;
Ptr myMainAddr;
#if defined(__VMS) || defined(__DARWIN__)
m_handle = dlopen(libname.c_str(), 0); // The second parameter is ignored
-#else
+#else // !__VMS && !__DARWIN__
int rtldFlags = 0;
- if( flags & wxDL_LAZY )
+ if ( flags & wxDL_LAZY )
{
wxASSERT_MSG( (flags & wxDL_NOW) == 0,
_T("wxDL_LAZY and wxDL_NOW are mutually exclusive.") );
+#ifdef RTLD_LAZY
rtldFlags |= RTLD_LAZY;
+#else
+ wxLogDebug(_T("wxDL_LAZY is not supported on this platform"));
+#endif
}
- else if( flags & wxDL_NOW )
+ else if ( flags & wxDL_NOW )
{
+#ifdef RTLD_NOW
rtldFlags |= RTLD_NOW;
+#else
+ wxLogDebug(_T("wxDL_NOW is not supported on this platform"));
+#endif
}
- if( flags & wxDL_GLOBAL )
+
+ if ( flags & wxDL_GLOBAL )
{
-#ifdef __osf__
- wxLogDebug(_T("WARNING: RTLD_GLOBAL is not a supported on this platform."));
-#endif
+#ifdef RTLD_GLOBAL
rtldFlags |= RTLD_GLOBAL;
+#else
+ wxLogDebug(_T("RTLD_GLOBAL is not supported on this platform."));
+#endif
}
- m_handle = dlopen(libname.c_str(), rtldFlags);
-#endif // __VMS || __DARWIN__
+ m_handle = dlopen(libname.fn_str(), rtldFlags);
+#endif // __VMS || __DARWIN__ ?
#elif defined(HAVE_SHL_LOAD)
int shlFlags = 0;
{
shlFlags |= BIND_IMMEDIATE;
}
- m_handle = shl_load(libname.c_str(), BIND_DEFERRED, 0);
+ m_handle = shl_load(libname.fn_str(), BIND_DEFERRED, 0);
#elif defined(__WINDOWS__)
m_handle = ::LoadLibrary(libname.c_str());
-
#else
-#error "runtime shared lib support not implemented"
+ #error "runtime shared lib support not implemented on this platform"
#endif
if ( m_handle == 0 )
{
wxString msg(_("Failed to load shared library '%s'"));
#if defined(HAVE_DLERROR) && !defined(__EMX__)
- const wxChar *err = dlerror();
+
+#if wxUSE_UNICODE
+ wxWCharBuffer buffer = wxConvLocal.cMB2WC( dlerror() );
+ const wxChar *err = buffer;
+#else
+ const wxChar *err = dlerror();
+#endif
+
if( err )
wxLogError( msg, err );
#else
DosQueryProcAddr( m_handle, 1L, name.c_str(), (PFN*)symbol );
#elif defined(HAVE_DLOPEN) || defined(__DARWIN__)
- symbol = dlsym( m_handle, name.c_str() );
+ symbol = dlsym( m_handle, name.fn_str() );
#elif defined(HAVE_SHL_LOAD)
- if( shl_findsym( &m_handle, name.c_str(), TYPE_UNDEFINED, &symbol ) != 0 )
+ if( shl_findsym( &m_handle, name.fn_str(), TYPE_UNDEFINED, &symbol ) != 0 )
symbol = 0;
#elif defined(__WINDOWS__)
{
wxString msg(_("wxDynamicLibrary failed to GetSymbol '%s'"));
#if defined(HAVE_DLERROR) && !defined(__EMX__)
+
+#if wxUSE_UNICODE
+ wxWCharBuffer buffer = wxConvLocal.cMB2WC( dlerror() );
+ const wxChar *err = buffer;
+#else
const wxChar *err = dlerror();
+#endif
+
if( err )
{
failed = TRUE;
info = wxClassInfo::sm_first;
while( info->m_next && info->m_next != m_after ) info = info->m_next;
- wxASSERT_MSG( info, _T("ClassInfo from wxPluginLibrary not found on purge"))
+ wxASSERT_MSG( info, _T("ClassInfo from wxPluginLibrary not found on purge"));
info->m_next = m_before;
}
#if WXWIN_COMPATIBILITY_2_2
-wxDllType wxDllLoader::LoadLibrary(const wxString &name)
+wxDllType wxDllLoader::LoadLibrary(const wxString &name, bool *success)
{
wxPluginLibrary *p = wxPluginManager::LoadLibrary
(
wxDL_DEFAULT | wxDL_VERBATIM | wxDL_NOSHARE
);
+ if ( success )
+ *success = p != NULL;
+
return p ? p->GetLibHandle() : 0;
}