Hi,
i am new to eC and i am trying make a application where i deliver a binary which is the application and allow the users to extend the application by making 'plugins' that are loaded dynamically on application start.
would this be possible with eC?
Dynamic loading/plugins
Re: Dynamic loading/plugins
Hi Heiko!
Welcome to eC! This is totally possible, and made easy.
The plugins projects must be set up as dynamic library (.dll/.so/.dylib).
Say you would like to load all plugins from a folder, you can use the FileListing class to iterate through the files in a folder, and load them with eModule_Load(), e.g. if the plugin is called myplugin.dll/libmyplugin.so/libmyplugin.dylib :
This will give you a module handle, from which you can find a class and instantiate it:
A common approach would be to define a base class with virtual methods in the application, which your plugin class can derive from and override the methods it wants to implement.
Please let me know if you have more questions regarding this after you try it out. Good luck!
Best regards,
Jerome
Welcome to eC! This is totally possible, and made easy.
The plugins projects must be set up as dynamic library (.dll/.so/.dylib).
Say you would like to load all plugins from a folder, you can use the FileListing class to iterate through the files in a folder, and load them with eModule_Load(), e.g. if the plugin is called myplugin.dll/libmyplugin.so/libmyplugin.dylib :
Code: Select all
Module module = eModule_Load(__thisModule, "myplugin", publicAccess);
Code: Select all
Class c = eSystem_FindClass(module, "MyPluginClass");
eInstance_New(c);
Please let me know if you have more questions regarding this after you try it out. Good luck!
Best regards,
Jerome