I have written a DLL. I want to register plugins in my project.
This is how the plugin manager looks like:
extern "C" class PluginManager
{
private:
list<IPlugin*> pluginRegistry;
public:
PluginManager();
void registerPlugin(IPlugin * plugin);
list<IPlugin*> getPlugins();
void loadPlugins();
virtual ~PluginManager();
protected:
};
and this is my library:
#include "PluginManager.h"
#include "BinFilter.cpp"
#include "BoxFilter.cpp"
#include <list>
extern "C" void RegisterPlugins(PluginManager * manager){
manager->registerPlugin(new BoxFilter);
manager->registerPlugin(new BinFilter);
}
But I have an error:
./src/plugins/lib1.so: undefined symbol: _ZN13PluginManager14registerPluginEP7IPlugin
How to avoid it?
UPD:
System is ubuntu, compiler g++
dlopen opens my file, but an error appear when I try to call IPlugin method
dlopen and dlsym called this way :
char * newName = (char *) calloc(strlen(entry->d_name)+14, 1);
strcpy(newName, "./src/plugins/");
strcat(newName, entry->d_name);
void * h = dlopen (newName, RTLD_NOW) ;
#typedef FUNCTION = "RegisterPlugins";
typedef void (*func_t)(PluginManager *);
func_t func = (func_t) dlsym(h, FUNCTION);
UPD:
I found out what the problem was. I closed library before calling function from it.