1
//////////////////////////////////////////////////////////////////////////////
2
//////////////////////////////////////////////////////////////////////////////
4
// copyright : (C) 2008 by Eran Ifrah
5
// file name : dynamiclibrary.cpp
7
// -------------------------------------------------------------------------
10
// / __ \ | | | | (_) |
11
// | / \/ ___ __| | ___| | _| |_ ___
12
// | | / _ \ / _ |/ _ \ | | | __/ _ )
13
// | \__/\ (_) | (_| | __/ |___| | || __/
14
// \____/\___/ \__,_|\___\_____/_|\__\___|
18
// This program is free software; you can redistribute it and/or modify
19
// it under the terms of the GNU General Public License as published by
20
// the Free Software Foundation; either version 2 of the License, or
21
// (at your option) any later version.
23
//////////////////////////////////////////////////////////////////////////////
24
//////////////////////////////////////////////////////////////////////////////
25
#include "dynamiclibrary.h"
27
#if defined(__WXMAC__) || defined(__WXGTK__)
29
# include "precompiled_header.h"
32
clDynamicLibrary::clDynamicLibrary()
33
#if defined(__WXMAC__) || defined(__WXGTK__)
39
clDynamicLibrary::~clDynamicLibrary()
41
#if defined(__WXMAC__) || defined(__WXGTK__)
49
bool clDynamicLibrary::Load(const wxString &name)
51
#if defined (__WXMSW__)
52
return m_lib.Load(name, wxDL_NOSHARE);
55
#if defined(__WXGTK__) && defined (ON_64_BIT)
56
// on GTK we need to pass RTLD_DEEPBIND otherwise symbols clashes
57
m_dllhandle = dlopen(_C(name), RTLD_LAZY| RTLD_LOCAL | RTLD_DEEPBIND);
59
m_dllhandle = dlopen(_C(name), RTLD_LAZY);
63
wxString error = wxString(dlerror(), wxConvUTF8);
70
void clDynamicLibrary::Detach()
72
#if defined (__WXMSW__)
82
void *clDynamicLibrary::GetSymbol(const wxString &name, bool *success)
84
#if defined (__WXMSW__)
86
void *symb = m_lib.GetSymbol(name, &rc);
90
dlerror(); // reset errors
93
void *symb = dlsym(m_dllhandle, _C(name));
103
bool clDynamicLibrary::IsLoaded()
105
#if defined (__WXMSW__)
106
return m_lib.IsLoaded();
108
return m_dllhandle != NULL;