QPluginLoader cannot load a dll with MKL library calls
-
Hi All,
I am trying to load my plug-in module like below:
@
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
QObject *plugin = loader.instance();
@I found if the dll file doesn't make Intel MKL calls, it can be loaded; otherwise it cannot be loaded(plugin pointer is null). Does any one know reasons? or how to fix it? Thanks a lot.
myfeng
[EDIT: code formatting, please wrap in @-tags, Volker]
-
Maybe some MKL dlls can't be found?
Otherwise, please be more precise. What do you mean with "dll file doesn’t make Intel MKL calls". Will the MKL still loaded in this case?What says QPluginLoader::errorString()?
-
[quote author="Franzk" date="1298961225"]Did you cast the plugin pointer to your plug-in interface?
@QPluginLoader loader(filename);
MyPlugin *plugin = qobject_cast<MyPlugin *>(loader.interface());
if (plugin) {
// ...
}
//...
@[/quote]This cannot work. If the instance pointer, which is of type QObject, is already null it cannot be casted to a QObject derived pointer. A null pointer always yields another null pointer if casted.
-
-
Good point, r2d3, "QLibrary":http://doc.qt.nokia.com/4.7/qlibrary.html should be the way to go (unless your DLL is actually a Qt plugin).
QPluginLoader":http://doc.qt.nokia.com/4.7/qpluginloader.html is for Qt plugins only:
bq. QPluginLoader provides access to a Qt plugin. A Qt plugin is stored in a shared library (a DLL) and offers these benefits over shared libraries accessed using QLibrary....
-
[quote author="Volker" date="1298987063"]If the instance pointer, which is of type QObject, is already null it cannot be casted to a QObject derived pointer.[/quote]My mistake there. I misread the post to say that the instance pointer was non-null, thereby assuming that there was some object casting to be done.
-
[quote author="Franzk" date="1299003220"]My mistake there. I misread the post to say that the instance pointer was non-null, thereby assuming that there was some object casting to be done.
[/quote]No problem - that's the nice thing on Qt DevNet: There's almost always someone who does kind-of proof reading - and it saved some others from my own crap several times :-)
-
A third solution is to change directory to the plugin directory as Windows is also searching for DLL in the current directory.
"Search Path Used by Windows to Locate a DLL":http://msdn.microsoft.com/en-us/library/7d83bc18(v=vs.80).aspx