I am using QPluginLoader to build a QT application, using the Qt Plugin framework.
I have built a plugin, but the framework is failing to load the plugin. My plugin has a dependency on a third party shlib (log4qt).
The file is correctly identified, but loading the file fails (this immediately made me suspect a missing dependency).
I run ldd on the shlib, and in the output, this is the only missing file:
liblog4qt.so.1 => not found
I have tried the following to resolve the problem:
- Using QApplication::addtLibraryPath("Path to liblog4qt.*)
- Edited /etc/ld.conf to manually add library location and refreshed cache
- Copied all of the liblog4qt* files into my plugin directory
All of the above were as much use as a chocolate fireguard.
Here is how I am loading the plugin. Nothing unsual here ...
// Private methods
void MyApp::loadPlugins()
{
//QString path = QApplication::applicationDirPath();
QDir plugins_dir(".");
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
QString pdirname = plugins_dir.dirName().toLower();
#if defined(Q_OS_WIN)
if (dirname == "debug") || (dirname="release")
plugins_dir.cdUp();
#elif defined(Q_OS_MAC)
if (dirname == "macos")
{
plugins_dir.cdUp();
plugins_dir.cdUp();
plugins_dir.cdUp();
}
#endif
#endif
plugins_dir.cd("bin/plugins");
foreach(QString filename, plugins_dir.entryList(QDir::Files))
{
qDebug() << "Filename: " << filename;
if (!filename.toLower().contains("plugin"))
continue;
qDebug() << "Attempting to load: " << plugins_dir.absoluteFilePath(filename);
QPluginLoader plugin_loader(plugins_dir.absoluteFilePath(filename));
QString problem = plugin_loader.errorString();
qDebug() << "Plugin load problem: " << problem;
QObject * plugin = plugin_loader.instance();
if (plugin)
{
PluginInterface * iplugin = qobject_cast<PluginInterface *>(plugin);
if (iplugin) {
/* do something useful */
}
}
}
}
Here is the (relevant part of the) console output:
14-09-27 15:50:42.SSS [DEBUG] Qt: - Attempting to load: "/path/to//main/bin/plugins/libplugin001.so"
14-09-27 15:51:33.SSS [DEBUG] Qt: - Plugin load problem: "Unknown error"
14-09-27 15:51:53.SSS [DEBUG] Qt: - Attempting to load: "/path/to//main/bin/plugins/libplugin001.so.1"
14-09-27 15:51:53.SSS [DEBUG] Qt: - Plugin load problem: "Unknown error"
14-09-27 15:51:55.SSS [DEBUG] Qt: - Attempting to load: "/path/to//main/bin/plugins/libplugin001.so.1.0"
14-09-27 15:51:55.SSS [DEBUG] Qt: - Plugin load problem: "Unknown error"
14-09-27 15:51:57.SSS [DEBUG] Qt: - Attempting to load: "/path/to//main/bin/plugins/libplugin001.so.1.0.0"
14-09-27 15:51:57.SSS [DEBUG] Qt: - Plugin load problem: "Unknown error"
Does anyone know why my plugin library is NOT being loaded?
[[Additional Information]]
- OS: Ubuntu 12.0.4 LTS
- gcc: 4.6.3
- QT: 4.8.1
- QT Creator: 2.4.1