How to import QML plugins?
-
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 theint main...
code aboveand 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?
-
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 theint main...
code aboveand 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?
-
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 theint main...
code aboveand 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?
-
@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.
-
@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.