C
Chris
Hi,
first of all: sorry if this is not a pure C++ question, it is somewhat
OS-specific but I think it fits here best.
I have a base system with capabilities for loading plugings. Plugins
comply to a given interface and can be loaded using LoadLibrary/
dlopen. To access the plugin-object itself I use a function in every
plugin that has a predefined name using:
extern "C" __declspec(dllexport) ModuleInterface* createModule
(unsigned long id)
{
return new SpecialPlugin ();
}
This way I call GetProcAddress/dlsym to get the function pointer and
execute it to get the plugin-object in my base system.
This all works fine but I have two problems:
1. the plugin-object is created in the address-space of the DLL and
thus it can not natively use the objects (singletons) in the base
system
2. some functionality that the plugins use is in the base system.
Naturally I get linker errors if I do not compile this functionality
into each and every plugin _and_ the base system. (some of this
functionality is made up of singletons which then (see problem 1) get
instanceiated in each plugin, too)
Any suggestions on how to solve the problems or change the design to
something better are welcome!
Thanks,
Chris
first of all: sorry if this is not a pure C++ question, it is somewhat
OS-specific but I think it fits here best.
I have a base system with capabilities for loading plugings. Plugins
comply to a given interface and can be loaded using LoadLibrary/
dlopen. To access the plugin-object itself I use a function in every
plugin that has a predefined name using:
extern "C" __declspec(dllexport) ModuleInterface* createModule
(unsigned long id)
{
return new SpecialPlugin ();
}
This way I call GetProcAddress/dlsym to get the function pointer and
execute it to get the plugin-object in my base system.
This all works fine but I have two problems:
1. the plugin-object is created in the address-space of the DLL and
thus it can not natively use the objects (singletons) in the base
system
2. some functionality that the plugins use is in the base system.
Naturally I get linker errors if I do not compile this functionality
into each and every plugin _and_ the base system. (some of this
functionality is made up of singletons which then (see problem 1) get
instanceiated in each plugin, too)
Any suggestions on how to solve the problems or change the design to
something better are welcome!
Thanks,
Chris