Add LIBS-paths to PATH before running on windows.

On windows when linking to a library via -L/some/path, the library is
found in /some/path while linking. But running that app fails, since it
can't find the library. We now adjust PATH to include all paths from
LIBS and thus the library is found.
This commit is contained in:
dt
2010-03-29 15:17:04 +02:00
parent 58497e46a6
commit a67e88993b
3 changed files with 25 additions and 1 deletions

View File

@@ -1177,6 +1177,7 @@ void Qt4ProFileNode::applyEvaluate(bool parseResult, bool async)
m_projectDir,
QStringList() << m_projectDir,
0);
newVarValues[LibDirectoriesVar] = libDirectories(m_readerExact);
if (m_varValues != newVarValues) {
m_varValues = newVarValues;
@@ -1355,6 +1356,17 @@ QStringList Qt4ProFileNode::includePaths(ProFileReader *reader) const
return paths;
}
QStringList Qt4ProFileNode::libDirectories(ProFileReader *reader) const
{
QStringList result;
foreach (const QString &str, reader->values(QLatin1String("LIBS"))) {
if (str.startsWith("-L")) {
result.append(str.mid(2));
}
}
return result;
}
QStringList Qt4ProFileNode::subDirsPaths(ProFileReader *reader) const
{
QStringList subProjectPaths;

View File

@@ -91,7 +91,8 @@ enum Qt4Variable {
UiDirVar,
MocDirVar,
PkgConfigVar,
PrecompiledHeaderVar
PrecompiledHeaderVar,
LibDirectoriesVar
};
class Qt4PriFileNode;
@@ -277,6 +278,7 @@ private:
QStringList uiDirPaths(ProFileReader *reader) const;
QStringList mocDirPaths(ProFileReader *reader) const;
QStringList includePaths(ProFileReader *reader) const;
QStringList libDirectories(ProFileReader *reader) const;
QStringList subDirsPaths(ProFileReader *reader) const;
TargetInformation targetInformation(ProFileReader *reader) const;

View File

@@ -550,6 +550,16 @@ ProjectExplorer::Environment Qt4RunConfiguration::baseEnvironment() const
if (m_isUsingDyldImageSuffix) {
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
// to find those libraries while actually running we explicitly prepend those
// dirs to the path
Qt4ProFileNode *node = qt4Target()->qt4Project()->rootProjectNode()->findProFileFor(m_proFilePath);
if (node)
foreach(const QString dir, node->variableValue(LibDirectoriesVar))
env.prependOrSetPath(dir);
#endif
return env;
}