Linux C/C++ : How to reload dynamic modules?
- by Arman
Hi, Are there way to reload dynamic library?
I am loading module by dlopen library:
bool load_functions(){
std::string function_name="libfunction-factory.so";
void* handle = dlopen(function_name.c_str(), RTLD_NOW);
//some initialization and usage
// '''
// unload the library
dlclose(handle);
return true;
}
int main()
{
int i=0;
for(;;)
{
cout<<"##prompt##"<<i++<<">";
if(std::cin.get()=='q')
break;
else
{
if(!load_functions())
std::cout<<"Failed to load Function Factory..."<<std::endl;
}
cout<<endl;
}
return 0;
}
after running I am editing library and trying to reload the library, but the new library does not load. Always the first loaded library is used. Are there way to force to reload library? Why dlclose does not unload library?
Kind regards
Arman.