PDA

View Full Version : where/what are static plugins?



ht1
11th January 2008, 17:43
Hello all!

I've been desperately trying to compile Qt4.3.3 in static mode and I've never gotten the static mode to work. I suspect that I don't know how to build static plugins or I declare them wrong. To be honest with you, I've no clue what they are.
The main question I need to answer first is: do I have the right plugins. This brings me to asking 3 very general questions.

With Qt4.3.3 compiled in static mode and using mingw:

1. Where do the static plugins reside? I'm especially interested in imageformats plugins. Are imageformats plugins supposed to be in "plugins/imageformats"?
2. What are the names and file extentions of static imageformat plugins (or any other plugins for that matter)? How do I recognize a plugin? I've never had a confirmed sighting of a static plugin in all my years? To me they are UFOs.
3. Once you pick up a scent of your mysterious static plugin and track it down and corner it and prevent it from escaping, how do you then test if your plugin is functional and built right?

Yours,
ht1

jacek
12th January 2008, 19:38
Where do the static plugins reside? I'm especially interested in imageformats plugins. Are imageformats plugins supposed to be in "plugins/imageformats"?
In the same place as normal plugins would be, so in case of image format plugins it will be $QTDIR/plugins/imageformats.


What are the names and file extentions of static imageformat plugins (or any other plugins for that matter)? How do I recognize a plugin?
A static plugin is a plugin turned into a static library, so that you can link it with your application. If you use GCC toolchain, they will have .a extension.


how do you then test if your plugin is functional and built right?
If you use the plugin correctly, there should be no linker errors and the plugin should appear in the command line that as -lpluginname. See the documentation for Q_IMPORT_PLUGIN macro.

ht1
14th January 2008, 17:11
Thanks. I think I have the static plugins because in the "plugins/imageformats" I have:
libqgif.a, libqjpeg.a, libqmng.a, libqsvg.a, libqtiff.a.

In my main.cpp I declare:


#include <QtPlugin>
Q_IMPORT_PLUGIN(libqjpeg)
Q_IMPORT_PLUGIN(libqgif)
Q_IMPORT_PLUGIN(libqmng)


And myproject.pro has:


CONFIG += staticlib
QTPLUGIN += libqjpg \
libqgif \
libqmng


I also put the static plugins files in the same folder with my .pro file. Still the compiler says that "-llibjpg" not found. What I am doing wrong? Compilation works if I don't make the above declarations in the main.cpp and myproject.pro file.

jacek
14th January 2008, 18:41
Those plugins are named "qjpeg", "qgif" and "qmng".

ht1
14th January 2008, 21:06
The plugins that I have in my "plugins/imageformats" are not qjpeg, qgif and qmng. They are libqgif.a, libqjpeg.a, libqmng.a, libqsvg.a, libqtiff.a.
Does that mean I failed to build static plugins?
How do you build static plugins with mingw?

jacek
14th January 2008, 21:33
They are libqgif.a, libqjpeg.a, libqmng.a, libqsvg.a, libqtiff.a.
No these are files with plugins inside. ;) Just remove the "lib" prefix from .pro file and macros in main.cpp.

ht1
14th January 2008, 22:05
Jacek, thanks,

Now myproject.pro is


TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += staticlib
QTPLUGIN += qjpg \
qgif \
qmng

but I'm still getting "cannot find -lqjpg". I tried to compile with and without this is main.cpp:

Q_IMPORT_PLUGIN(qjpeg)
Q_IMPORT_PLUGIN(qgif)
Q_IMPORT_PLUGIN(qmng)

but still I get the "cannot find -lqjpg" error.

Is there anything else I could try to diagnose the problem? Thanks

jacek
14th January 2008, 22:07
It should be qjpeg.

ht1
15th January 2008, 15:21
Thanks, I changed "qjpg" to "qjpeg" in the *.pro file. Now the compiler says:

main.cpp: undefined reference to 'qt_plugin_instance_qjpeg()'
main.cpp: undefined reference to 'qt_plugin_instance_qgif()'
main.cpp: undefined reference to 'qt_plugin_instance_qmng()'

Is it possible that my static plugins are in the wrong folder? Where do they need to be?

ht1
16th January 2008, 15:25
I was wondering that perhaps there is something wrong with the way I declare the plugins in my main.cpp. This is how I do it:



#include <QtPlugin>

Q_IMPORT_PLUGIN(qjpeg)
Q_IMPORT_PLUGIN(qgif)
Q_IMPORT_PLUGIN(qmng)


Is there anyone out there who has compiled Qt4 statically and has linked imageformat plugins statically to the executable? I have tried just about every combination of everything but nothing works. This problem is causing me a major problems. Thanks!

jacek
16th January 2008, 15:26
Do you use qmake from the static Qt build?

ht1
16th January 2008, 18:09
Yes, indeed, I use QMAKE from static Qt build. Also, I am able to incorporate other static plugins no problem, just not the imageformat static plugins. Taking these plugins out makes the program to compile fine but unable to handle image files (because the plugins were not incorporated). So, I think the compiler is fine and the code is fine. It's either that imageformat plugins have a problem, or I do not declare them right, or they are not in the right folder.

jacek
16th January 2008, 19:07
Could you post the command used to link your application (the one where the g++ is invoked with -l options)?

Do you get any other error messages apart from "undefined reference to qt_plugin_instance_xxx"?

ht1
16th January 2008, 20:23
Great, Jacek, you may have figured out what the problem is. I do not know how to link properly using the command line. I've been doing:

1) prompt>qmake -project
2) then manually add the plugin info to the myproject.pro as shown in an earlier post
3) prompt>qmake
4) prompt>make

I guess I have to use -l in step 4?? How?
Thanks again

jacek
16th January 2008, 20:29
I guess I have to use -l in step 4?? How?
Actually make should do that for you. What is the last command it runs?

ht1
16th January 2008, 22:30
Hi Jacek,

The last command I run when I compile is
prompt> make
I don't know if that's what you meant when you asked about the last command?

The last thing the compiler does before giving error message is:
-LC:/Qt/4.3.3/plugins/imageformats/ -lqmng4 -lQtGui -ldgi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtCore -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws_32
(hopefully I didn't make mistakes copying it down)

jacek
16th January 2008, 22:34
I don't know if that's what you meant when you asked about the last command?
I asked you about the last command that make runs.

Run:
make > aaa.txt
After make finishes its job, open aaa.txt and find the line with lots of "-l<something>" (it should be near the end of that file) and post it here.

ht1
16th January 2008, 22:40
Hi again.

I didn't find the aaa.txt but
the last thing the compiler does before giving error message is:

-LC:/Qt/4.3.3/plugins/imageformats/ -lqmng4 -lQtGui -ldgi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtCore -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws_32

ht1
16th January 2008, 22:50
Jacek, you are asking a very good question about the compiler. The compiler says:

-LC:/Qt/4.3.3/plugins/imageformats/ -lqmng4 -lQtGui -ldgi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtCore -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws_32

but my working directory is Qt/static, not Qt/4.3.3. Seems like the system is confused about the folder where imageformat flugins are. What does that mean?

I just put the imageformat plugins in the folder that compiler wants. Now the error is:
"cannot find -lqjpeg4"

jacek
16th January 2008, 23:09
What does that mean?
It means that most likely you were using the wrong qmake.

Run:
make clean
C:\Qt\static\bin\qmake
make

ht1
16th January 2008, 23:17
Jacek, you are a genius! Thank you so much, your suggestion worked and now everything is perfect!

After two weeks of banging my head against the wall!

vietdoor
23rd June 2011, 10:58
Hi all,

How to use and build the jpg plugin on QtCreator?

I got the error = undefined reference to `qt_plugin_instance_qjpeg()'

guitronic
18th August 2013, 11:42
Hi all,

How to use and build the jpg plugin on QtCreator?

I got the error = undefined reference to `qt_plugin_instance_qjpeg()'
Hi all
try use Q_IMPORT_PLUGIN(QJPEGPlugin) for Qt 5.0.2 is good ;)