D
diegofsantos
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
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.
Here are a piece of my code that loads the libs:
while ( (temp=man->getActiveNameFromFile())!=NULL)
{
void *dlib;
dlib = dlopen(temp,RTLD_NOW|RTLD_GLOBAL);
liblist.push_back(dlib);
if (dlib == NULL)
{
fl_alert(dlerror());
}
}
Note that I put all handles (void *) in a std::list. The dlopen
works fine, all libs are loaded.
Then, I try to unload all libs as the following:
std::list<void *>::iterator it;
for (it=liblist.begin(); it!=liblist.end(); it++)
if (dlclose(*it))
printf("\nErro\n");
But the applications always crash here.
I have tried to use dlclose in reverse order too without success.
Please, can anyone help me?
I'd like to load and unload the shared libs dynamically, but I
couldn't unload it.
Thanks in advance,
Diego
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
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.
Here are a piece of my code that loads the libs:
while ( (temp=man->getActiveNameFromFile())!=NULL)
{
void *dlib;
dlib = dlopen(temp,RTLD_NOW|RTLD_GLOBAL);
liblist.push_back(dlib);
if (dlib == NULL)
{
fl_alert(dlerror());
}
}
Note that I put all handles (void *) in a std::list. The dlopen
works fine, all libs are loaded.
Then, I try to unload all libs as the following:
std::list<void *>::iterator it;
for (it=liblist.begin(); it!=liblist.end(); it++)
if (dlclose(*it))
printf("\nErro\n");
But the applications always crash here.
I have tried to use dlclose in reverse order too without success.
Please, can anyone help me?
I'd like to load and unload the shared libs dynamically, but I
couldn't unload it.
Thanks in advance,
Diego