[SOLVED] QPluginLoader unable to load a Qt Plugin
-
wrote on 27 Mar 2015, 13:36 last edited by bharath144
Hello all,
I have an Interface as shown below.
class MyInterface { public: virtual ~MyInterface() {} virtual int initialize() = 0; }; Q_DECLARE_INTERFACE(MyInterface, "com.example.MyInterface/1.0")
My plugin implements this interface and declares it in its class as shown below.
class QT_DECL_EXPORT MyPlugin : public QObject, public MyInterface { Q_OBJECT Q_INTERFACES(MyInterface) public: MyPlugin(); virtual ~MyPlugin(); public: int initialize(); // ... };
My plugin's project file sets the target appropriately.
TARGET = $$qtLibraryTarget(MyPlugin) TEMPLATE = lib
Now, all the modules (including my app) gets compiled. In the app where I have to load the plugin, I have the following code:
// ... QPluginLoader loader("MyPluginld.dll"); if (! loader.load()) qDebug() << "Error!"; MyInterface *base = qobject_cast<MyInterface *>(loader.instance()); if (base == NULL) qDebug() << "Error!"; // ...
The
loader.load()
function always fails. Am I making a mistake by providing incorrect name to theQPluginLoader
constructor? Or is something else wrong?Any help would be much appreciated.
Cheers!
Bharath -
wrote on 27 Mar 2015, 20:10 last edited by
In your code you expect that the DLL is in the same directory of the executable.
Is that TRUE?? -
In your code you expect that the DLL is in the same directory of the executable.
Is that TRUE??wrote on 30 Mar 2015, 05:57 last edited by@mcosta Yes, that is correct. My deployment model ensures that both land up in the same directory.
Cheers!
ಮೈ ಗೋ ಭರತ ನಾರಾಯಣ
Bharath Narayan M G -
wrote on 30 Mar 2015, 06:18 last edited by
Hi,
if your DLL is in the right place you can use
QPluginLoader::errorString()
to understand whyload
fails -
Hi,
if your DLL is in the right place you can use
QPluginLoader::errorString()
to understand whyload
failswrote on 30 Mar 2015, 06:34 last edited by@mcosta Thanks for that. I will see what the error string says.
-
Hi,
if your DLL is in the right place you can use
QPluginLoader::errorString()
to understand whyload
failswrote on 30 Mar 2015, 06:37 last edited by bharath144@mcosta
The errorString prints the following:"Plugin verification data mismatch in './/MyPluginld.dll'"
-
wrote on 30 Mar 2015, 07:21 last edited by
@bharath144 said:
Plugin verification data mismatch in
Had a quick look to Qt sources.
Seems that you must use this macro to define plugin's metadata.Reading here, the point 3. of "Writing a plugin involves these steps:" says the same thing
-
@bharath144 said:
Plugin verification data mismatch in
Had a quick look to Qt sources.
Seems that you must use this macro to define plugin's metadata.Reading here, the point 3. of "Writing a plugin involves these steps:" says the same thing
wrote on 30 Mar 2015, 09:46 last edited by@mcosta That did the trick. I saw the step but I overlooked it thinking it may not be mandatory.
Thanks for the help.
-
wrote on 11 May 2015, 09:06 last edited by LeaA 5 Dec 2015, 07:08
hello,
can you tell us how you solve your problem?
thank you.