summaryrefslogtreecommitdiffstats
path: root/src/tools/windeployqt/main.cpp
diff options
context:
space:
mode:
authorTimothée Keller <timothee.keller@qt.io>2023-04-11 16:38:49 +0200
committerTimothée Keller <timothee.keller@qt.io>2023-04-17 16:24:59 +0200
commit94279afff86252b8b777450a56990fa33ffbb0d7 (patch)
treed8170ac2446f4fdaa65da39ad245acd584791963 /src/tools/windeployqt/main.cpp
parenta03fdd65eee733fa59cb4df5e3d3609caf17df8d (diff)
Windeployqt: change MinGW dll's import location
The MinGW runtimes were imported through the PATH, which creates mismatches with the expected libraries that are installed directly through Qt. Check if those can be used instead, and issue a warning (and default to PATH) if not. Fixes: QTBUG-112448 Pick-to: 6.5 Change-Id: I061baabb6d6188bd0817b68c39a5d9f04ff391b5 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/tools/windeployqt/main.cpp')
-rw-r--r--src/tools/windeployqt/main.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/tools/windeployqt/main.cpp b/src/tools/windeployqt/main.cpp
index bec0291ae2..093e21e36c 100644
--- a/src/tools/windeployqt/main.cpp
+++ b/src/tools/windeployqt/main.cpp
@@ -1084,25 +1084,30 @@ static QString vcRedistDir()
return QString();
}
-static QStringList compilerRunTimeLibs(Platform platform, bool isDebug, unsigned short machineArch)
+static QStringList compilerRunTimeLibs(const QString &qtBinDir, Platform platform, bool isDebug, unsigned short machineArch)
{
QStringList result;
switch (platform) {
- case WindowsDesktopMinGW: { // MinGW: Add runtime libraries
+ case WindowsDesktopMinGW: { // MinGW: Add runtime libraries. Check first for the Qt binary directory, and default to path if nothing is found.
static const char *minGwRuntimes[] = {"*gcc_", "*stdc++", "*winpthread"};
- const QString gcc = findInPath(QStringLiteral("g++.exe"));
- if (gcc.isEmpty()) {
- std::wcerr << "Warning: Cannot find GCC installation directory. g++.exe must be in the path.\n";
- break;
- }
- const QString binPath = QFileInfo(gcc).absolutePath();
QStringList filters;
const QString suffix = u'*' + sharedLibrarySuffix(platform);
for (auto minGwRuntime : minGwRuntimes)
filters.append(QLatin1StringView(minGwRuntime) + suffix);
- const QFileInfoList &dlls = QDir(binPath).entryInfoList(filters, QDir::Files);
+
+ QFileInfoList dlls = QDir(qtBinDir).entryInfoList(filters, QDir::Files);
+ if (dlls.isEmpty()) {
+ std::wcerr << "Warning: Runtime libraries not found in Qt binary folder, defaulting to path\n";
+ const QString gcc = findInPath(QStringLiteral("g++.exe"));
+ if (gcc.isEmpty()) {
+ std::wcerr << "Warning: Cannot find GCC installation directory. g++.exe must be in the path.\n";
+ break;
+ }
+ const QString binPath = QFileInfo(gcc).absolutePath();
+ dlls = QDir(binPath).entryInfoList(filters, QDir::Files);
+ }
for (const QFileInfo &dllFi : dlls)
- result.append(dllFi.absoluteFilePath());
+ result.append(dllFi.absoluteFilePath());
}
break;
#ifdef Q_OS_WIN
@@ -1435,7 +1440,7 @@ static DeployResult deploy(const Options &options, const QMap<QString, QString>
options.directory : options.libraryDirectory;
QStringList libraries = deployedQtLibraries;
if (options.compilerRunTime)
- libraries.append(compilerRunTimeLibs(options.platform, result.isDebug, machineArch));
+ libraries.append(compilerRunTimeLibs(qtBinDir, options.platform, result.isDebug, machineArch));
for (const QString &qtLib : std::as_const(libraries)) {
if (!updateLibrary(qtLib, targetPath, options, errorMessage))
return result;