【问题标题】:Failed to load platform plugin "windows", even with platforms/qwindows.dll and libEGL.dll无法加载平台插件“windows”,即使使用平台/qwindows.dll 和 libEGL.dll
【发布时间】:2014-01-04 03:51:37
【问题描述】:

当我尝试在另一台计算机上执行我的 qt 程序时,我收到此错误并崩溃:

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

我知道这个问题已经在其他几个问题中讨论过:

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

但是我已经应用了建议的解决方案,但它仍然对我不起作用。相关资料:

  • 我使用 Qt 5.1.0 和 MinGW 4.8 32bit 进行开发

  • 在我的开发电脑(Win7,64 位)上,程序执行得很好

  • 我在发布模式下编译了我的应用程序

  • 目标电脑(Win7,32位)没有安装Qt

  • 我的 .pro 的一部分:

    QT += core gui opengl network xml testlib

    目标 = 我的应用程序

    模板 = 应用程序

    CONFIG += qtestlib 帮助

    CONFIG -= app_bundle

  • 我的部署文件夹的内容:

    myApp.exe

    [所有 dll,在我的开发环境的 .exe 文件夹中]

    [来自 Qt/5.1.0/5.1.0/mingw48_32/bin 的所有 dll]

    [来自 Qt/5.1.0/Tools/mingw48_32/bin 的所有 dll](包括 libEGL.dll、libEGLd.dll、libGLESv2.dll、libGLESv2d.dll)

    [来自 Qt/5.1.0/Tools/QtCreator/bin 的所有 dll]

    平台/qwindows.dll

【问题讨论】:

    标签: windows mingw32 qt5.1


    【解决方案1】:

    我遇到了与 qwindows.dll 相同的问题 -- win7 64 ok,win7 32 失败,无法找到 qwindows.dll

    首先我检查了我可以使用 -platformpluginpath 运行它:

    app.exe -platformpluginpath plugins/platforms 
    

    一切正常,所以问题只是应用程序内的搜索路径错误。 最后我只添加了所有可能的路径:

    #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();
    }
    

    【讨论】:

      猜你喜欢
      • 2013-07-15
      • 2013-02-04
      • 2013-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-01
      • 2013-07-23
      相关资源
      最近更新 更多