Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to import QML plugins?
Qt 6.11 is out! See what's new in the release blog

How to import QML plugins?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 987 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Roberrt
    wrote on last edited by Roberrt
    #1

    I have Qt compiled static, but when I run my application I get this error:

    qrc:/files/particles/particles.qml:2:1: module "QtQuick.Particles" plugin "particlesplugin" not found 
         import QtQuick.Particles 2.0 
         ^
    

    My imports related to QML are these:

    import QtQuick 2.5
    import QtQuick.Particles 2.0
    

    I tried to follow the documentation:

    #include <QtPlugin>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);     
        Q_IMPORT_PLUGIN(QtQuick2Plugin)
        Q_IMPORT_PLUGIN(QtQuick2ParticlesPlugin) // <--- cause error
        Q_IMPORT_PLUGIN(QtQmlMetaPlugin)
        Q_IMPORT_PLUGIN(QtQmlPlugin)
        Q_IMPORT_PLUGIN(QtQmlModelsPlugin)
        Q_IMPORT_PLUGIN(QtQmlWorkerScriptPlugin)
    

    But I'm getting this compilation error:

    1>main.obj : error LNK2019: unresolved external symbol "struct QStaticPlugin const __cdecl qt_static_plugin_QtQuick2ParticlesPlugin(void)" (?qt_static_plugin_QtQuick2ParticlesPlugin@@YA?BUQStaticPlugin@@XZ) referenced in function main
    

    I searched the source for proper way to import this plugin and I have found it at C:\Qt\6.6.0_static\qtdeclarative\src\particles

    in the file particlesplugin_init.cpp:

    #include <QtPlugin>
    Q_IMPORT_PLUGIN(QtQuick2ParticlesPlugin)
    

    Why is the compilation throwing that error?

    I'm compiling using Visual Studio 2022.

    I tested adding #pragma comment(lib, "particlesplugin.lib") into the int main... code above

    and the compiler complained about not finding the lib.

    I have them added to my project properties:

    C/C++ -> General -> Additional Include Directories -> C:\Qt\6.6.0_static\qml\QtQuick\Particles
    
    Linker -> Input -> particlesplugin.lib
    

    When recompiled, now I'm getting a different error:

    1>particlesplugin.lib(particlesplugin_QtQuick2ParticlesPlugin.cpp.obj) : error LNK2019: unresolved external symbol "void __cdecl qml_register_types_QtQuick_Particles(void)" (?qml_register_types_QtQuick_Particles@@YAXXZ) referenced in function "public: static __cdecl `public: static void (__cdecl*__cdecl QtPrivate::QMetaTypeForType<class QtQuick2ParticlesPlugin>::getDefaultCtr(void))(class QtPrivate::QMetaTypeInterface const *,void *)'::`5'::<lambda_1>::<lambda_invoker_cdecl>(class QtPrivate::QMetaTypeInterface const *,void *)" (?<lambda_invoker_cdecl>@<lambda_1>@?4??getDefaultCtr@?$QMetaTypeForType@VQtQuick2ParticlesPlugin@@@QtPrivate@@SAP6AXPEBVQMetaTypeInterface@4@PEAX@ZXZ@SA@01@Z)
    

    I also get this external symbol error for every other QtQuick plugin that I try to import using Q_IMPORT_PLUGIN and not only the particlesplugin.

    I can't find anything about this in the documentation, what's going on?

    JoeCFDJ R 2 Replies Last reply
    0
    • R Roberrt

      I have Qt compiled static, but when I run my application I get this error:

      qrc:/files/particles/particles.qml:2:1: module "QtQuick.Particles" plugin "particlesplugin" not found 
           import QtQuick.Particles 2.0 
           ^
      

      My imports related to QML are these:

      import QtQuick 2.5
      import QtQuick.Particles 2.0
      

      I tried to follow the documentation:

      #include <QtPlugin>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);     
          Q_IMPORT_PLUGIN(QtQuick2Plugin)
          Q_IMPORT_PLUGIN(QtQuick2ParticlesPlugin) // <--- cause error
          Q_IMPORT_PLUGIN(QtQmlMetaPlugin)
          Q_IMPORT_PLUGIN(QtQmlPlugin)
          Q_IMPORT_PLUGIN(QtQmlModelsPlugin)
          Q_IMPORT_PLUGIN(QtQmlWorkerScriptPlugin)
      

      But I'm getting this compilation error:

      1>main.obj : error LNK2019: unresolved external symbol "struct QStaticPlugin const __cdecl qt_static_plugin_QtQuick2ParticlesPlugin(void)" (?qt_static_plugin_QtQuick2ParticlesPlugin@@YA?BUQStaticPlugin@@XZ) referenced in function main
      

      I searched the source for proper way to import this plugin and I have found it at C:\Qt\6.6.0_static\qtdeclarative\src\particles

      in the file particlesplugin_init.cpp:

      #include <QtPlugin>
      Q_IMPORT_PLUGIN(QtQuick2ParticlesPlugin)
      

      Why is the compilation throwing that error?

      I'm compiling using Visual Studio 2022.

      I tested adding #pragma comment(lib, "particlesplugin.lib") into the int main... code above

      and the compiler complained about not finding the lib.

      I have them added to my project properties:

      C/C++ -> General -> Additional Include Directories -> C:\Qt\6.6.0_static\qml\QtQuick\Particles
      
      Linker -> Input -> particlesplugin.lib
      

      When recompiled, now I'm getting a different error:

      1>particlesplugin.lib(particlesplugin_QtQuick2ParticlesPlugin.cpp.obj) : error LNK2019: unresolved external symbol "void __cdecl qml_register_types_QtQuick_Particles(void)" (?qml_register_types_QtQuick_Particles@@YAXXZ) referenced in function "public: static __cdecl `public: static void (__cdecl*__cdecl QtPrivate::QMetaTypeForType<class QtQuick2ParticlesPlugin>::getDefaultCtr(void))(class QtPrivate::QMetaTypeInterface const *,void *)'::`5'::<lambda_1>::<lambda_invoker_cdecl>(class QtPrivate::QMetaTypeInterface const *,void *)" (?<lambda_invoker_cdecl>@<lambda_1>@?4??getDefaultCtr@?$QMetaTypeForType@VQtQuick2ParticlesPlugin@@@QtPrivate@@SAP6AXPEBVQMetaTypeInterface@4@PEAX@ZXZ@SA@01@Z)
      

      I also get this external symbol error for every other QtQuick plugin that I try to import using Q_IMPORT_PLUGIN and not only the particlesplugin.

      I can't find anything about this in the documentation, what's going on?

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      @Roberrt If you add this (static?)qtquick2plugin.lib with its path to your app, I guess it will be ok.

      1 Reply Last reply
      0
      • R Roberrt

        I have Qt compiled static, but when I run my application I get this error:

        qrc:/files/particles/particles.qml:2:1: module "QtQuick.Particles" plugin "particlesplugin" not found 
             import QtQuick.Particles 2.0 
             ^
        

        My imports related to QML are these:

        import QtQuick 2.5
        import QtQuick.Particles 2.0
        

        I tried to follow the documentation:

        #include <QtPlugin>
        
        int main(int argc, char *argv[])
        {
            QApplication a(argc, argv);     
            Q_IMPORT_PLUGIN(QtQuick2Plugin)
            Q_IMPORT_PLUGIN(QtQuick2ParticlesPlugin) // <--- cause error
            Q_IMPORT_PLUGIN(QtQmlMetaPlugin)
            Q_IMPORT_PLUGIN(QtQmlPlugin)
            Q_IMPORT_PLUGIN(QtQmlModelsPlugin)
            Q_IMPORT_PLUGIN(QtQmlWorkerScriptPlugin)
        

        But I'm getting this compilation error:

        1>main.obj : error LNK2019: unresolved external symbol "struct QStaticPlugin const __cdecl qt_static_plugin_QtQuick2ParticlesPlugin(void)" (?qt_static_plugin_QtQuick2ParticlesPlugin@@YA?BUQStaticPlugin@@XZ) referenced in function main
        

        I searched the source for proper way to import this plugin and I have found it at C:\Qt\6.6.0_static\qtdeclarative\src\particles

        in the file particlesplugin_init.cpp:

        #include <QtPlugin>
        Q_IMPORT_PLUGIN(QtQuick2ParticlesPlugin)
        

        Why is the compilation throwing that error?

        I'm compiling using Visual Studio 2022.

        I tested adding #pragma comment(lib, "particlesplugin.lib") into the int main... code above

        and the compiler complained about not finding the lib.

        I have them added to my project properties:

        C/C++ -> General -> Additional Include Directories -> C:\Qt\6.6.0_static\qml\QtQuick\Particles
        
        Linker -> Input -> particlesplugin.lib
        

        When recompiled, now I'm getting a different error:

        1>particlesplugin.lib(particlesplugin_QtQuick2ParticlesPlugin.cpp.obj) : error LNK2019: unresolved external symbol "void __cdecl qml_register_types_QtQuick_Particles(void)" (?qml_register_types_QtQuick_Particles@@YAXXZ) referenced in function "public: static __cdecl `public: static void (__cdecl*__cdecl QtPrivate::QMetaTypeForType<class QtQuick2ParticlesPlugin>::getDefaultCtr(void))(class QtPrivate::QMetaTypeInterface const *,void *)'::`5'::<lambda_1>::<lambda_invoker_cdecl>(class QtPrivate::QMetaTypeInterface const *,void *)" (?<lambda_invoker_cdecl>@<lambda_1>@?4??getDefaultCtr@?$QMetaTypeForType@VQtQuick2ParticlesPlugin@@@QtPrivate@@SAP6AXPEBVQMetaTypeInterface@4@PEAX@ZXZ@SA@01@Z)
        

        I also get this external symbol error for every other QtQuick plugin that I try to import using Q_IMPORT_PLUGIN and not only the particlesplugin.

        I can't find anything about this in the documentation, what's going on?

        R Offline
        R Offline
        Roberrt
        wrote on last edited by Roberrt
        #3

        @JoeCFD hi, i dont understand what do you mean

        JoeCFDJ 1 Reply Last reply
        0
        • R Roberrt

          @JoeCFD hi, i dont understand what do you mean

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by JoeCFD
          #4

          @Roberrt If you link static Qt to your app, I guess its plugins are static as well, right? If yes, you may have to add the static plugins manually to your build.

          R 1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            @Roberrt If you link static Qt to your app, I guess its plugins are static as well, right? If yes, you may have to add the static plugins manually to your build.

            R Offline
            R Offline
            Roberrt
            wrote on last edited by
            #5

            @JoeCFD said in How to import QML plugins?:

            you may have to add the static plugins manually to your build.

            This is what I'm trying to understand, i tried Q_IMPORT_QML_PLUGIN(qtquick2plugin) but im getting that compilation error.

            JoeCFDJ 1 Reply Last reply
            0
            • R Roberrt

              @JoeCFD said in How to import QML plugins?:

              you may have to add the static plugins manually to your build.

              This is what I'm trying to understand, i tried Q_IMPORT_QML_PLUGIN(qtquick2plugin) but im getting that compilation error.

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by JoeCFD
              #6

              @Roberrt Maybe type the following:
              how to add static qt qml plugin to app build
              to chatgpt to see what you get.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved