When building statically you may need to explicit load the .qrc resource file using the Q_INIT_RESOURCE macro:
Qt Code:
Q_INIT_RESOURCE(Backgrounds);To copy to clipboard, switch view to plain text mode
This should be done in the main.cpp file before the QApplication is constructed, if I'm not mistaken.
By the way: This was my first post, so I really hope it helps![]()
Plan everything. Document everything. Version control everything. Test everything. Deny everything.
This is what i have done so far.question is whether you have static plugins built in the first place
.pro
CONFIG += static
QTPLUGIN += qjpeg
main.cpp
#include <QtPlugin>
Q_IMPORT_PLUGIN(qjpeg)
I am getting an link(LINK2019) error. I also notice that the word 'QTPLUGIN' isn't showing up in a violet color like the other QT commands do? I have a imageformats folder(next to my .exe) with libqjpeg.a in it. What else am i doing wrong?
What is the error? My crystal ball is out of action...![]()
main.obj:-1: error: LNK2019: unresolved external symbol "class QObject * __cdecl qt_plugin_instance_qjpeg(void)" (?qt_plugin_instance_qjpeg@@YAPAVQObject@@XZ) referenced in function "public: __thiscall StaticqjpegPluginInstance::StaticqjpegPluginInstan ce(void)" (??0StaticqjpegPluginInstance@@QAE@XZ)
debug\interface.exe:-1: error: LNK1120: 1 unresolved externals
Forget the imageformats folder, it's only for dynamic plugins. The static plugins need to be available at compile time where the linker can find them.
Have you built Qt statically?
You need to build your application with a static version of Qt, not just configure your project for a static build. If you have built both Qt and your application statically you should not need any Qt related dll's. In any event, when using qrc files you do not need to deploy the image files after compilation, they will be built inn to your executable.
From the error message it looks like the linker can't find the static version of the qjpeg library, indicating either a faulty path or that you don't have the qjpeg static library. Static files will most likely be .a files if you are using the MinGW compiler, and .lib if you are using msvc.
If all you want is for your images to show in the application, perhaps the dynamic approach is the better one, using qrc resource files. If you need to deploy your application as a part of your job, then static build may be the way to go, however you do need a commercial Qt license to deploy static Qt applications.
Plan everything. Document everything. Version control everything. Test everything. Deny everything.
Bookmarks