Plugin won't load [Solved]
-
Interface class declared:
@class QApplication;class _interface
{
public:
virtual ~_interface();
virtual void start_plugin( QApplication* ) = 0;
};Q_DECLARE_INTERFACE( _interface, "ru.home.plugin._interface/1.5")
@Class declared
@
#include <QObject>
#include "_interface.h"class QApplication;
class main_plugin : public QObject, public _interface {
Q_OBJECT
Q_INTERFACES( _interface )public:
virtual ~main_plugin(){}
virtual void start_plugin( QApplication * );
};@Class implemented
@MainWindow glpMainWindow;
void main_plugin::start_plugin( QApplication a )
{
glpMainWindow = new MainWindow( a );
glpMainWindow->show();
return;
}Q_EXPORT_PLUGIN2( _interface, main_plugin )@
.pro file beginning for plugin
@TARGET = pluginapp
TEMPLATE = lib
CONFIG += plugin@plugin loading inside parent application:
@ QDir dir( QApplication::applicationDirPath() );
QPluginLoader PluginLoader( dir.absoluteFilePath("pluginapp.dll") );
QObject* pluginapp = qobject_cast<QObject*>( PluginLoader.instance() );@pluginapp is NULL nothing more hapiness,
pluginapp.dll definetely exists in main app folder
the call of QString errstr = PluginLoader.errorString(); after this gives errstr == "Unknown error"stall... what's wrong? how to define error?
-
I made empty plugin, without useful code and tried this:
@ a->addLibraryPath( a->applicationDirPath() );
QPluginLoader PluginLoader( "EmptyPlugin.dll" /abspath/ );
QObject* CI_FED = qobject_cast<QObject*>( PluginLoader.instance() );@same effect, dead end...
ANYBODY KNOWING Qt PLUGINS - PLEASE HELP!
-
@ QPluginLoader PluginLoader();
PluginLoader.setFileName( "EmptyPlugin.dll" );
QString plugname = PluginLoader.fileName();@plugname is empty... what is going on here??? :-0
-
Even the code
@ QPluginLoader PluginLoader("I:\Qt\2010.05s\projects\SCPS-M-build-desktop\debug\pluginapp.dll");
QString abspath = PluginLoader.fileName();@
or
@ QPluginLoader PluginLoader("I:/Qt/2010.05s/projects/SCPS-M-build-desktop/debug/pluginapp.dll");
QString abspath = PluginLoader.fileName();@doesn't work, abspath is empty but the file pluginapp.dll definitely exists and path is correct
ANYBODY CAN CONFIRM OR DECLINE THIS?
I'm going post bug report...
-
SOLVED. Application was made static because of wrong Qt selected in it's project. Dynamically linked plugins don't work with static applications.
But the error message must be more informative. It would save my time.
-
[quote author="Gourmand" date="1307541728"]SOLVED. Application was made static because of wrong Qt selected in it's project. Dynamically linked plugins don't work with static applications.
But the error message must be more informative. It would save my time.
[/quote]Reading docs saves time as well. It's clearly stated at least in the "plugins howto":http://doc.qt.nokia.com/4.7/plugins-howto.html#static-plugins and in the "deployment guide":http://doc.qt.nokia.com/latest/deployment.html#static-vs-shared-libraries
-
I read this all and remembered plugins are only for dynamic linking. But if only QPluginLoader told me error state "Plugins are not supported in static application" - then I'd solve problem much earlier. The bug is in error processing code in QPluginLoader. It returns wrong error state: "Unknown error".