I read about libraries and plugins, and I see that if I want to import whole class, I need to declare my library as plugin. So i did something like this:
my lib:
class MAILSYSTEMSHARED_EXPORT MainlLib
: public QObject{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDummyPlugin")
public:
}
class MAILSYSTEMSHARED_EXPORT MainlLib : public QObject
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDummyPlugin")
public:
MainLib(QString variable);
}
To copy to clipboard, switch view to plain text mode
loading in main.cpp:
QObject *object
= loader
->instance
();
MainLib *lib = qobject_cast<MainLib *>(object);
QPluginLoader *loader = new QPluginLoader("Mailboxes/lib/libMainLib.so");
QObject *object = loader->instance();
MainLib *lib = qobject_cast<MainLib *>(object);
To copy to clipboard, switch view to plain text mode
Now if I have parameters in MainLib, I get no matching function for call to MainLib::MainLib(), candidate is MainLib::MainLib(QString, QString, QString), in file moc_MainLib.cpp
When I remove parameters, in main program I get: undefined reference to `MainLib::staticMetaObject'
What should I do?
Thanks
Bookmarks