Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Unknown error loading plugin in Design Mode on Windows



  • I built the qmlextensionplugins example using Qt 11.1, QtCreator 4.7.1 and MSVC2017 on Windows. I'm loading the generated plugin in a simple QtQuick project displaying the clock in a window.

    If I build and run the example it works well.

    But if I opend the qml in Design Mode I have an error near the Window component and the plugin components are not loaded.

    The error is the following:
    found not working imports: file:///C:/XXX/main.qml:3 plugin cannot be loaded for module "TimeExample": cannot load library C:\XXX\TimeExample\qmlqtimeexampleplugin.dll: Unknown error 0x000000c1

    I tried with other plugins with the same result. Instead the same code works well also in Design mode on Linux and macOs.

    The project files are the following:

    main.qml

    import QtQuick 2.11
    import QtQuick.Window 2.11
    import TimeExample 1.0
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        Clock { // this class is defined in QML (imports/TimeExample/Clock.qml)
    
            Time { // this class is defined in C++ (plugin.cpp)
                id: time
            }
    
            hours: time.hour
            minutes: time.minute
    
        }
    }
    

    main.cpp

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QDebug>
    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        QList<QQmlError> errors;
        engine.addImportPath("C:\\XXX\\imports");
        for(auto e: errors)
            qDebug() << e.toString();
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
        if (engine.rootObjects().isEmpty())
            return -1;
    
        return app.exec();
    }
    

    example.pro:

    QT += quick
    CONFIG += c++11
    
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS QT_DEBUG_PLUGINS QML_IMPORT_TRACE
    
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
            main.cpp
    
    RESOURCES += qml.qrc
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH = C:\XXX\imports
    QML2_IMPORT_PATH = C:\XXX\imports
    QT_PLUGIN_PATH = C:\XXX\imports
    
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    QML_DESIGNER_IMPORT_PATH = C:\XXX\imports
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    

    How can I fix this problem?



  • Hi!

    On Windows QtCreator is a 32 bit application and can hence only load 32 bit DLLs. I suspect your plugin is a 64 bit DLL.

    Christian


Log in to reply