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?
This issue is a bug, follow the bugreport: https://bugreports.qt.io/browse/QTVSADDINBUG-1173
Qt/MSBuild is not providing all the necessary link dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With