I have a problem with a dynamic library in a Cocoa application.
On a button action, I load a dylib, resolv a function in it and executes it, like the following :
void* handle = dlopen("blah.dylib", RTLD_LAZY);
if (!handle)
{
NSLog(@"dlopen() failure : %s", dlerror());
return;
}
function_to_resolv p = (function_to_resolv)dlsym(handle, "function_to_resolv");
function_to_resolv();
if (dlclose(handle) != 0)
NSLog(@"FAIL");
All works fine, except that the library is never unloaded from the binary.
I verified it with the following code :
const uint32_t s = _dyld_image_count();
for (uint32_t i = 0; i < s; i++)
{
const char* str = _dyld_get_image_name(i);
NSLog(@"%s", str);
}
Why could be the reason of this ?