Failed to load platform plugin "windows", even with platforms/qwindows.dll and libEGL.dll

1.4k views Asked by At

When I try to execute my qt program on another computer, I receive this error and crash:

Failed to load platform plugin "windows". Available platforms are:
windows

I know that this problem has been discussed in several other questions:

failed to load platform plugin "windows" Available platforms are: windows, minimal

Qt application: Failed to load platform plugin "windows". Available platforms are:

PyQt5 - Failed to load platform plugin "windows". Available platforms are: windows, minimal

But I have applied the suggested solutions, and it still doesn't work for me. Relevant information:

  • I use Qt 5.1.0 with MinGW 4.8 32bit for development

  • on my development pc (Win7, 64bit) the program executes just fine

  • I compiled my application in release mode

  • the target pc (Win7, 32bit) does not have Qt installed

  • part of my .pro:

    QT += core gui opengl network xml testlib

    TARGET = myApp

    TEMPLATE = app

    CONFIG += qtestlib help

    CONFIG -= app_bundle

  • content of my deployment folder:

    myApp.exe

    [all dlls, that are in the .exe folder of my development environment]

    [all dlls from Qt/5.1.0/5.1.0/mingw48_32/bin]

    [all dlls from Qt/5.1.0/Tools/mingw48_32/bin] (including libEGL.dll, libEGLd.dll, libGLESv2.dll, libGLESv2d.dll)

    [all dlls from Qt/5.1.0/Tools/QtCreator/bin]

    platforms/qwindows.dll

1

There are 1 answers

0
dima_weber On

I had same issue with qwindows.dll -- win7 64 ok, win7 32 fail with unable to find qwindows.dll

first of all i checked i can run it with -platformpluginpath:

app.exe -platformpluginpath plugins/platforms 

everything ok, so the problem is just wrong search pathes inside app. I ended with just adding all possible pathes:

#include <QApplication>
#include <QDir>

void registerPluginsDir(QDir& exeDir)
{
#ifdef Q_OS_MAC
        QString pluginsRelPath = "/../../PlugIns";
#elif defined(Q_OS_WIN)
        QString pluginsRelPath = "Plugins";
#elif defined (Q_OS_LINUX)
        QString pluginsRelPath = "../lib/plugins";
#else
       #error "Unsupported OS"
#endif

    QString platformsRelPath = "platforms";
    QString pluginsPath = exeDir.absoluteFilePath(pluginsRelPath);
    QString platformsPath = QDir(pluginsPath).absoluteFilePath(platformsRelPath);
    QStringList pathes = QCoreApplication::libraryPaths();
    pathes << pluginsPath;
    pathes << platformsPath;
    pathes << platformsRelPath;
    pathes << pluginsRelPath;
    QCoreApplication::setLibraryPaths(pathes);
}

int main(int argc, char *argv[])
{
    QString exePath = QString::fromUtf8(argv[0]);
    QFileInfo exeInfo (exePath);
    QDir exeDir (exeInfo.absolutePath());

    //need to set correct plugins path before app instance created
    registerPluginsDir(exeDir);

    QApplication app(argc, argv);
    // more code here

    return app.exec();
}