From: Christian Kamm Date: Wed, 27 Apr 2011 11:21:24 +0000 (+0200) Subject: Set LD_LIBRARY_PATH in unix run environments. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d7d23226babe11019177741307b8fef3913a2faa;p=qt-creator-jp%2Fqt-creator-jp.git 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 --- diff --git a/src/libs/utils/environment.cpp b/src/libs/utils/environment.cpp index 20f822f38c..6ea9ce9d3e 100644 --- a/src/libs/utils/environment.cpp +++ b/src/libs/utils/environment.cpp @@ -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()); diff --git a/src/libs/utils/environment.h b/src/libs/utils/environment.h index a2a0bf8a06..4c9a0792ed 100644 --- a/src/libs/utils/environment.h +++ b/src/libs/utils/environment.h @@ -85,6 +85,8 @@ public: void appendOrSetPath(const QString &value); void prependOrSetPath(const QString &value); + void prependOrSetLibrarySearchPath(const QString &value); + void clear(); int size() const; diff --git a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp index ef4e8e0909..f524212b10 100644 --- a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp @@ -600,15 +600,13 @@ Utils::Environment Qt4RunConfiguration::baseEnvironment() const env.set("DYLD_IMAGE_SUFFIX", "_debug"); } -#ifdef Q_OS_WIN - // On windows the user could be linking to a library found via a -L/some/dir switch + // The user could be linking to a library found via a -L/some/dir switch // to find those libraries while actually running we explicitly prepend those - // dirs to the path + // dirs to the library search path const Qt4ProFileNode *node = qt4Target()->qt4Project()->rootProjectNode()->findProFileFor(m_proFilePath); if (node) foreach(const QString &dir, node->variableValue(LibDirectoriesVar)) - env.prependOrSetPath(dir); -#endif + env.prependOrSetLibrarySearchPath(dir); return env; } diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index 35614af204..4bd0d55b75 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -1722,6 +1722,7 @@ void QtVersion::addToEnvironment(Utils::Environment &env) const // Generic: env.set("QTDIR", QDir::toNativeSeparators(versionInfo().value("QT_INSTALL_DATA"))); env.prependOrSetPath(versionInfo().value("QT_INSTALL_BINS")); + env.prependOrSetLibrarySearchPath(versionInfo().value("QT_INSTALL_LIBS")); // Symbian specific: if (supportsTargetId(Constants::S60_DEVICE_TARGET_ID)