> Can you explain why you need to load symbols globally instead of
> locally?
When I try to load symbols locally, I can load and unload libs, but my
application doesnt work fine. I have a base class for all plugins
named moduleBase, as the following:
class moduleBase
{
public:
.
.
.
virtual void setInput (itk:

ataObject *in);
virtual void setInput (itk:

ataObject *in, int port);
virtual itk:

ataObject *getOutput();
virtual itk:

ataObject *getOutput(int port);
virtual bool update();
virtual bool run();
void init_module();
.
.
.
The problem is the following: the output of one plugin is an input of
another, and so on... and in the plugin .cxx file I do casting
(itk:

ataObject to another type). When I load symbols locally, I
can't do the casting... here is the error:
"cannot cast PKN3itk10DataObjectE to PKN3itk9ImageBaseILJ3EEE"
But if I load the libs with RTLD_GLOBAL, then all works fine.
Could you help me? May I have load the symbols locally ? How can I
solve this problem?
Thanks in advance,
Diego
On Mar 28, 3:15 pm, Piyo <cybermax...@yahoo.com> wrote:
> diegofsan...@gmail.com wrote:
> > Hi,
> > I have created an C++ application that uses shared libs (plugins -
> > object factories). I need
> > to load and unload the libs at run time.
> > I need to open the shared libs with RTLD_GLOBAL parameter and I open
>
> Can you explain why you need to load symbols globally instead of
> locally?
>
> > all shared libs without any problems. But when I try to unload the
> > libs (dlclose), my application crashs (segmentation fault). If I dont
> > use RTLD_GLOBAL, all works fine.
>
> It may be the case that some symbol in all of your plugin is trumping
> a symbol in your global namespace on loading. Then you unload it but the
> program still requires that symbol. This might cause your problem.
>
> Other sources of shared libs crashes are globals
> (static or otherwise) or hanging onto any references to objects
> instantiated by your plugin. If you do not destroy all globals and/or
> refs to objects and then you unload the plugin, the object destructor
> is now invalid.
>
> HTH!!