diff options
author | David Faure <faure+bluesystems@kde.org> | 2012-12-03 12:29:10 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-04 18:38:41 +0100 |
commit | 418890e0748384eb684f33b10dc6f32493aee54b (patch) | |
tree | f3a6e1064e71046556466a92eda0fc7adcfebd04 /src/corelib/plugin/qlibrary_unix.cpp | |
parent | f6cc1f3aeae795e7ed67338b17b860df9f5146a7 (diff) |
QPluginLoader: fix loading of plugins with a relative file name
This makes QT_PLUGIN_PATH / QCoreApplication::libraryPaths() actually work,
as a search path for plugins, when apps look for a specific plugin by name.
To make it possible to write portable code (unlike the current QPluginLoader
unittest), let QPluginLoader figure out the extension, too.
Change-Id: I895d597d7cb05ded268734bc5f313f32d8d12cb9
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/plugin/qlibrary_unix.cpp')
-rw-r--r-- | src/corelib/plugin/qlibrary_unix.cpp | 100 |
1 files changed, 56 insertions, 44 deletions
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index 2ef6f80466..35d8197306 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -80,6 +80,60 @@ static QString qdlerror() return err ? QLatin1Char('(') + QString::fromLocal8Bit(err) + QLatin1Char(')'): QString(); } +QStringList QLibraryPrivate::suffixes_sys(const QString& fullVersion) +{ + QStringList suffixes; +#if defined(Q_OS_HPUX) + // according to + // http://docs.hp.com/en/B2355-90968/linkerdifferencesiapa.htm + + // In PA-RISC (PA-32 and PA-64) shared libraries are suffixed + // with .sl. In IPF (32-bit and 64-bit), the shared libraries + // are suffixed with .so. For compatibility, the IPF linker + // also supports the .sl suffix. + + // But since we don't know if we are built on HPUX or HPUXi, + // we support both .sl (and .<version>) and .so suffixes but + // .so is preferred. +# if defined(__ia64) + if (!fullVersion.isEmpty()) { + suffixes << QString::fromLatin1(".so.%1").arg(fullVersion); + } else { + suffixes << QLatin1String(".so"); + } +# endif + if (!fullVersion.isEmpty()) { + suffixes << QString::fromLatin1(".sl.%1").arg(fullVersion); + suffixes << QString::fromLatin1(".%1").arg(fullVersion); + } else { + suffixes << QLatin1String(".sl"); + } +#elif defined(Q_OS_AIX) + suffixes << ".a"; + +#else + if (!fullVersion.isEmpty()) { + suffixes << QString::fromLatin1(".so.%1").arg(fullVersion); + } else { + suffixes << QLatin1String(".so"); + } +#endif +# ifdef Q_OS_MAC + if (!fullVersion.isEmpty()) { + suffixes << QString::fromLatin1(".%1.bundle").arg(fullVersion); + suffixes << QString::fromLatin1(".%1.dylib").arg(fullVersion); + } else { + suffixes << QLatin1String(".bundle") << QLatin1String(".dylib"); + } +#endif + return suffixes; +} + +QStringList QLibraryPrivate::prefixes_sys() +{ + return QStringList() << QLatin1String("lib"); +} + bool QLibraryPrivate::load_sys() { QString attempt; @@ -96,50 +150,8 @@ bool QLibraryPrivate::load_sys() QStringList suffixes; QStringList prefixes; if (pluginState != IsAPlugin) { - prefixes << QLatin1String("lib"); -#if defined(Q_OS_HPUX) - // according to - // http://docs.hp.com/en/B2355-90968/linkerdifferencesiapa.htm - - // In PA-RISC (PA-32 and PA-64) shared libraries are suffixed - // with .sl. In IPF (32-bit and 64-bit), the shared libraries - // are suffixed with .so. For compatibility, the IPF linker - // also supports the .sl suffix. - - // But since we don't know if we are built on HPUX or HPUXi, - // we support both .sl (and .<version>) and .so suffixes but - // .so is preferred. -# if defined(__ia64) - if (!fullVersion.isEmpty()) { - suffixes << QString::fromLatin1(".so.%1").arg(fullVersion); - } else { - suffixes << QLatin1String(".so"); - } -# endif - if (!fullVersion.isEmpty()) { - suffixes << QString::fromLatin1(".sl.%1").arg(fullVersion); - suffixes << QString::fromLatin1(".%1").arg(fullVersion); - } else { - suffixes << QLatin1String(".sl"); - } -#elif defined(Q_OS_AIX) - suffixes << ".a"; - -#else - if (!fullVersion.isEmpty()) { - suffixes << QString::fromLatin1(".so.%1").arg(fullVersion); - } else { - suffixes << QLatin1String(".so"); - } -#endif -# ifdef Q_OS_MAC - if (!fullVersion.isEmpty()) { - suffixes << QString::fromLatin1(".%1.bundle").arg(fullVersion); - suffixes << QString::fromLatin1(".%1.dylib").arg(fullVersion); - } else { - suffixes << QLatin1String(".bundle") << QLatin1String(".dylib"); - } -#endif + prefixes = prefixes_sys(); + suffixes = suffixes_sys(fullVersion); } int dlFlags = 0; #if defined(QT_HPUX_LD) |