PDA

View Full Version : Error loading plugin dinamically



Zero
23rd January 2010, 15:56
Well, I'm trying to loading the echoplugin, inculded in the Qt's 4.6.0 package from my application but i can't done it. I'm compiling on Windows with Visual Studio and VS Add-in, all projects works fine, and if i compile the Echoplugin example, it loads the plugin fine, but my application can't do it.

Here is the function:


Programa::Programa(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags)
{
ui.setupUi(this);
QDir pluginsDir(qApp->applicationDirPath());
pluginsDir.cd("plugins");
foreach (QString fileName,pluginsDir.entryList(QDir::Files))
{
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName) );
QObject *plugin = pluginLoader.instance();

if (plugin)
{
QMessageBox::information(this,"xD","Plugin cargado!!! :D");
}
else
{
QMessageBox::information(this,"xD",pluginLoader.errorString());
}
}

return;
}

QPluginLoader::instance() returns always null, and the QPluginLoader::errorString() returns "Unknown Error". I think that the code isn't the problem, so i suspect that error could be in the project configuration. ?

Thanks in advance :)

wysota
23rd January 2010, 20:59
Make sure both your application and the plugin are built in the same mode (either debug or release).

Zero
23rd January 2010, 23:31
Well, finally i solve it, the error was the compilation mode, i was compiling my application statically, and Qt don't suport making statically linked applications pluggeables.

Tahnks :D