Glib::Module



Hi here follows the samplecode and the question is. I get no errors, it seems to load the moduleeee only when I try to acces the function via get_symbol() the sample app print this:
Name of the plugin: plugins/sample.dll
Error: `action': The specified procedure could not be found.

Sourcecode:
//======================================================================//

////The App////

//main.cpp
#include <iostream>
#include <glibmm/module.h>
#include "TestPluginApp_generic.h"
int main()
{
   void *actionpl = 0;
   Glib::Module plugin("plugins/sample.dll");
   if(!plugin)
       std::cout << "Error: " << plugin.get_last_error() << std::endl;
   else
   {
std::cout << "Name of the plugin: " << plugin.get_name() << std::endl;
       if(plugin.get_symbol("action", actionpl))
           std::cout << "Function exist" << std::endl;
       else
           std::cout << "Error: " << plugin.get_last_error() << std::endl;
   }
   return 0;
}
////////////////////////////////////////////////////////////////////////////////
//TestPluginApp_generic.h
#ifndef TESTPLUGINAPP_GENERIC_H
#define TESTPLUGINAPP_GENERIC_H
#ifdef __cplusplus
extern "C" {
#endif

class GenericPlugin
{
   public:
       virtual int action() = 0;
};

// This is the plugin function each plugin overrides for the main app to
// create an instance of the plugin child class.
extern GenericPlugin * CreatePlug();
//----------------------------------------------------------------------------
typedef GenericPlugin * (*CREATEPLUG_PROC)();

#ifdef __cplusplus
}
#endif
#endif //TESTPLUGINAPP_GENERIC_H

//======================================================================//
////The  module compile it as sample.dll////
////put this module in a 'plugin/' folder of the test app////

//sampleplugin.h
#ifndef SAMPLEPLUGIN_H
#define SAMPLEPLUGIN_H

#include "../testpluginapp_generic.h"

class SamplePlugin : public GenericPlugin
{
   public:
       virtual int action();
};

#endif //SAMPLEPLUGIN_H
////////////////////////////////////////////////////////////////////////////////
//sampleplugin.cpp
#include "../testpluginapp_generic.h"
#include "sampleplugin.h"
#include <iostream>

int SamplePlugin::action()
{
   std::cout << "Hello from SamplePlugin!" << std::endl;
   return 0;
}

GenericPlugin * CreatePlug()
{
   return new SamplePlugin;
}

//======================================================================//




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]