plugin system I'm writing, I have the following architecture:
program.exe // contains the main and it's linked dynamically to core.so
core.so // contains the plugin system manager and the host functionality
plugin.so // it's a plugin, not linked to anything, dynamically loaded by core.so
I'm doubting how to expose the host functionality to the plugins:
1) Rely on the linker (I fear this option because it may not be portable)
2) Rely on dlsym/GetProcAddress over the current process
3) Inject with a struct of pointers to functions the API from the host to the plugin in the initialization / register entry point
1 and 2: May work without big refactors but may not be portable
3: May imply a fully refactor of all plugins
What do you think about it? What option would you choose? Do you know any other option?
PD: All exposed APIs (plugins/host) are written in C for improving portability.
Boost::dll to the rescue.
that's already solved, I've got my own cross platform implementation for dlopen/GetProcAddress
THen just use no 2.
Redis does something like that: https://github.com/RedisLabs/RedisModulesSDK/blob/c0740b8209abae38775adc6f3fefe05a520be55b/redismodule.h#L791
Обсуждают сегодня