Hey,
i am currently trying to build a dylib which should be used as a plugin for another program. It should only have the function "RegisterPlugins()" visible to the Program which loads the plugin. I have nearly tried all possible settings in XCode, but unfortunatelly with no success so far
Here comes the declaration of the function:
Code:
__attribute__((visibility("default"))) void RegisterPlugins()
{
// my function body
}
And here the code which tries to load this function into the program:
Code:
// load dylib into address space
void* dylibHandle = dlopen( filename, RTLD_GLOBAL );
if (dylibHandle == NULL)
{
LogError("Failed to load the plugin library file (code=%d)", dlerror());
return false;
}
// get the address to the RegisterPlugins function inside the plugin
typedef void (*RegisterFunction)();
RegisterFunction registerFunction = (RegisterFunction)dlsym( dylibHandle, "RegisterPlugins" );
if (registerFunction == NULL)
{
LogError("Failed to find the RegisterPlugins function inside this plugin library (code=%d)", dlerror());
dlclose( dylibHandle );
return false;
}
(registerFunction)();
The opening of the library works fine and also no compile errors. But the registerFunction is always 0. So it tells that it has not found the plugin inside the plugin lib. I have set compileroption: -fvisibility=default which should also make all symbols visible i think. Also experimented with the EXPORTED_SYMBOLS_FILE option, with no success. Also tried the #pragma version of the gcc visibility without success...
Does anyone have an idea which setting could be wrong or what to adjust to get that working??? Hope you can help me. I'm glad about every small hint

!!! Thanks in advance!!
Regards, Hannes