0

Overview

I am trying to develop a C++ application which allows for user-created plugins.

I found a nice library called Pluma (http://pluma-framework.sourceforge.net/) which functionally seems to be exactly what I want.

After going through their tutorial, I was able to (with a bit of difficulty) convince the plugin to compile. However, it refuses to play nice and connect with the main program; returning various errors depending on how I try to implement them.

Problem

If I comment out the line labeled 'Main problem line' (in the last file, main.cpp), the plugin compiles successfully, and the main app can recognize it, but it says that "Nothing registered by plugin 'libRNCypher'", and none of the functions can be called.

If I compile that line, the main application instead says "Failed to load library 'Plugins/libRNCypher.so'. OS returned error: 'Plugins/libRNCypher.so: undefined symbol: _ZTIN5pluma8ProviderE".

My guess is that it has something to do with the way the plugin was compiled, as compiling it initially did not work and Code::Blocks told me to compile with "-fPIC" as a flag (doing so made it compile).

Code

Code below: Main.cpp

#include "Pluma/Pluma.hpp"
#include "CryptoBase.h"

int main()
{
pluma::Pluma manager;
manager.acceptProviderType< CryptoBaseProvider >();
manager.loadFromFolder("Plugins", true);

std::vector<CryptoBaseProvider*> providers;
manager.getProviders(providers);
return 0;
}

CryptoBase.h

#ifndef CRYPTOBASE_H_INCLUDED
#define CRYPTOBASE_H_INCLUDED

#include "Pluma/Pluma.hpp"

#include <string>
#include <vector>
#include <bitset>

//Base class from which all crypto plug-ins will derive
class CryptoBase
{
public:

CryptoBase();
~CryptoBase();

virtual std::string GetCypherName() const = 0;

virtual std::vector<std::string> GetCryptoRecApps() const = 0;

virtual void HandleData(std::vector< std::bitset<8> > _data) const = 0;

};

PLUMA_PROVIDER_HEADER(CryptoBase)

#endif // CRYPTOBASE_H_INCLUDED

RNCypher.h (This is part of the plugin)

#ifndef RNCYPHER_H_INCLUDED
#define RNCYPHER_H_INCLUDED

#include <string>
#include <vector>
#include <bitset>

#include "../Encoder/Pluma/Pluma.hpp"

#include "../Encoder/CryptoBase.h"

class RNCypher : public CryptoBase
{
public:

std::string GetCypherName() const
{
    return "RNCypher";
}

std::vector<std::string> GetCryptoRecApps() const
{
    std::vector<std::string> vec;
    vec.push_back("Storage");
    return vec;
}

void HandleData(std::vector< std::bitset<8> > _data) const
{
    char letter = 'v';
    _data.clear();
    _data.push_back(std::bitset<8>(letter));
    return;
}
};

PLUMA_INHERIT_PROVIDER(RNCypher, CryptoBase);

#endif // RNCYPHER_H_INCLUDED

main.cpp (This is part of the plugin)

#include "../Encoder/Pluma/Connector.hpp"
#include "RNCypher.h"

PLUMA_CONNECTOR
bool connect(pluma::Host& host)
{
host.add( new RNCypherProvider() ); //<- Main problem line
return true;
}

Additional Details

I'm compiling on Ubuntu 16.04, using Code::Blocks 16.01.

The second error message seems to not come from Pluma itself, but a file I also had to link, #include <dlfcn.h> (which might be a Linux file?).

I would prefer to use an existing library rather than write my own code as I would like this to be cross-platform. I am, however, open to any suggestions.

Sorry for all of the code, but I believe this is enough to reproduce the error that I am having.

Thank You

Thank you for taking the time to read this, and thank you in advance for your help!

All the best, and happy holidays!

  • Why the C tag for a C++ post? – chux - Reinstate Monica Dec 23 '16 at 03:17
  • When I demangle '_ZTIN5pluma8ProviderE' at https://demangler.com/ I get 'typeinfo for pluma::Provider;'. Maybe you are not linking some pluma library into your plugin. – brian beuning Dec 23 '16 at 03:24
  • The C tag was because 1. StackOverflow recommended it, and 2. figured it may have to do with some lower level memory management stuff – user7332956 Dec 23 '16 at 03:48
  • Thank you Brian, I will take a look at that and see if I'm missing something obvious. – user7332956 Dec 23 '16 at 03:49
  • So I took a look at it, and unfortunately, that was not the problem. You were correct in that the lib itself wasn't being included in the plugin, but even after resolving that, the error persists. I'd be interested if anyone has any other potential solutions. – user7332956 Dec 23 '16 at 05:05

1 Answers1

0

I was not able to reproduce your problem, however looking at http://pluma-framework.sourceforge.net/documentation/index.htm, I've noticed that:

Community
  • 1
  • 1
zizzo
  • 3
  • 3