简体   繁体   中英

Qt plugin not loaded

I have problems loading the built-in plugins for iconengines for a deployed application. Below is a minimal program to show the problem. It is not exactly the same, because Qt scans the plugin directories at start and registers it according to the file suffix, but I hope when I can get the minimal program to run, then the automatic scanning works, too.

main.cpp:

#include <QCoreApplication>
#include <QPluginLoader>
#include <QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QPluginLoader loader("C:/Qt/5.15.1/msvc2019_64/plugins/iconengines/qsvgicon.dll");
    if (loader.load()) {
        qDebug() << "load ok";
    } else {
        qDebug() << "load failed";
    }

    return a.exec();
}

and PluginTest.pro:

QT -= gui

CONFIG += c++11 console
CONFIG -= app_bundle

SOURCES += main.cpp

When I start it from the Qt Creator IDE, version 4.13.1, with Visual Studio 2019, 64 bit compiled, it prints "load ok". Now I do this from a "x64 Native Tools Command Prompt for VS 2019" command prompt in the project directory:

set PATH=%PATH%;C:\Qt\5.15.1\msvc2019_64\bin
mkdir deploy
copy release\PluginTest.exe deploy
windeployqt --release release\PluginTest.exe --plugindir deploy\QtPlugins

When I start PluginText.exe from the command prompt in the deploy directory, I get the output "load failed".

Additional information: when I set set qt_debug_plugins=1 and start the real application, I see these errors:

QFactoryLoader::QFactoryLoader() checking directory path "C:/projects/deploy/QtPlugins/iconengines" ...
QFactoryLoader::QFactoryLoader() looking at "C:/projects/deploy/QtPlugins/iconengines/qsvgicon.dll"
"Failed to extract plugin meta data from 'C:/projects/deploy/QtPlugins/iconengines/qsvgicon.dll'"
         not a plugin

The qsvgicon.dll file is identical to "c:\\Qt\\5.15.1\\msvc2019_64\\plugins\\iconengines\\qsvgicon.dll".

I found the problem. It used some other Qt DLLs from the path when starting the application. This fixed it:

xcopy /y c:\Qt\5.15.1\msvc2019_64\bin\*.dll deploy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM