Set LD_LIBRARY_PATH in unix run environments.

Similarly to how PATH is set up for Windows. The background is that
without it plugin loading can pull in incompatible Qt libraries if the
binary is compiled with RUNPATH instead of RPATH.

Reviewed-by: Daniel Teske
This commit is contained in:
Christian Kamm
2011-04-27 13:21:24 +02:00
parent 0c8b4e38fa
commit d7d23226ba
4 changed files with 27 additions and 5 deletions

View File

@@ -174,6 +174,27 @@ void Environment::prependOrSetPath(const QString &value)
prependOrSet(QLatin1String("PATH"), QDir::toNativeSeparators(value), QString(sep));
}
void Environment::prependOrSetLibrarySearchPath(const QString &value)
{
#ifdef Q_OS_WIN
const QChar sep = QLatin1Char(';');
#else
const QChar sep = QLatin1Char(':');
#endif
#ifdef Q_OS_WIN
const QLatin1String path("PATH");
#elif defined(Q_OS_MAC)
const QLatin1String path("DYLD_LIBRARY_PATH");
#elif defined(Q_OS_UNIX)
const QLatin1String path("LD_LIBRARY_PATH");
#else
return;
#endif
prependOrSet(path, QDir::toNativeSeparators(value), QString(sep));
}
Environment Environment::systemEnvironment()
{
return Environment(QProcess::systemEnvironment());