PDA

View Full Version : QPluginLoader not load plugin



Thyago.celler
17th May 2011, 20:55
Hello,

I have a problem, when I use QPluginLoader,the return is empty. But the path it is correct.

This is my code:


QDir dir( QCoreApplication::applicationDirPath());
dir.cdUp();
dir.cd("portal");

qDebug() << dir.absoluteFilePath(fileName);
QPluginLoader loader(" dir.absoluteFilePath(fileName)");

qDebug() << loader.isLoaded();
qDebug() << loader.errorString();
QObject *plugin = loader.instance();


The result in line :

1. qDebug() << dir.absoluteFilePath(fileName); is "path this is right", including the name file.

2. qDebug() << loader.isLoaded(); is "false"

3. qDebug() << loader.errorString(); is "unknow error".

and line:

Please, help me. =)

Thanks.

wysota
17th May 2011, 22:46
Does the plugin have the Q_EXPORT_PLUGIN2 macro?

ChrisW67
17th May 2011, 23:32
At line 6 you ask QPluginLoader to load a plugin called literally: " dir.absoluteFilePath(fileName)"

Remove the quotes.

Thyago.celler
18th May 2011, 15:11
Hi,

I remove the quotes, but did not difference.

Other question, where I put the macro Q_EXPORT_PLUGIN2 ?

Thank you very much.

wysota
18th May 2011, 15:24
In the implementation of the plugin, just like the docs state.

Thyago.celler
19th May 2011, 15:30
The problem is that, I not create the file .dll, he already exist in folder of project.

I just want import or load this file. That will I have that create the file .dll, ever that the project is compiled ?

thank you.

wysota
19th May 2011, 16:06
I don't understand what you mean. But to use the plugin, the macro needs to be there. You need to check if it is there.

ChrisW67
20th May 2011, 02:54
I think Thyago.celler wants to dynamically load an arbitrary library, not a Qt plugin. The correct class for this would be QLibrary not QPluginLoader.

Thyago.celler
20th May 2011, 17:49
But the that I'm doing this correct, but it returns me the following error :

Use incompatible Qt library. Expected build key ""Windows mingw debug full-config"" got, "Windows mingw release full-config";

Someone hnow the that can be this and why ?

Thank you.

wysota
20th May 2011, 19:01
Your application is built in debug mode and the library is built in release mode. They have to be built in the same mode (either debug or release).