PDA

View Full Version : Static linking problem with gif plugin, qt 4.6.2, vs 2008



colin207
16th March 2010, 16:02
Hi

Trying out a static build of Qt and am having problems getting the qt gif support to link in even when using Q_IMPORT_PLUGIN(qgif)

E.g if I build Qt (4.62, using VS 2008 on a vista box) using
configure -static -commercial -debug -qt-zlib -qt-libpng -qt-libtiff -qt-libjpeg -qt-gif -webkit -script -scripttools -no-phonon -no-phonon-backend -no-dbus -qt-sql-sqlite

...then I noticed that the Qt demo app 'browser' works fine but it does not display gif images.

Now I understand that with a statically linked Qt library you have to manually get the plugins linked in so I modified browsermainwindow.cpp to include:

#include <QApplication>
#include <QtPlugin>
Q_IMPORT_PLUGIN(qgif)


and I altered the .pro file to include
QTPLUGIN += qgif


... and then did qmake and a rebuild but now I get a linker error with


1>Linking...
1>LINK : debug\browser.exe not found or not built by the last incremental link; performing full link
1>LINK : warning LNK4068: /MACHINE not specified; defaulting to X86
1> Creating library debug\browser.lib and object debug\browser.exp
1>browsermainwindow.obj : error LNK2019: unresolved external symbol "class QObject * __cdecl qt_plugin_instance_qgif(void)" (?qt_plugin_instance_qgif@@YAPAVQObject@@XZ) referenced in function "public: __thiscall StaticqgifPluginInstance::StaticqgifPluginInstance (void)" (??0StaticqgifPluginInstance@@QAE@XZ)
1>debug\browser.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Qt\qt-everywhere-commercial-src-4.6.2\demos\browser\tmp\obj\debug_static\BuildLog. htm"
1>browser - 2 error(s), 1 warning(s)

What am I doing wrong?

Also, where in the Qt code does it control which plugins are automatically available in a statically linked app without having to do anything special? E.g. I noticed that the JPEG image plugin is automatically available within the statically linked browser demo without it having to use Q_IMPORT_PLUGIN. There must be some place within the Qt source where this is controlled.

Thanks for any suggestions.

Kevin Hoang
19th March 2010, 04:46
Same as me!
Hard to build static on QT, take long time, and many problems.

Bitto
19th March 2010, 13:55
I've at least verified that it works for me. I used this pro file:



SOURCES += main.cpp
QTPLUGIN += qgif


And this source file:



#include <QtGui>
Q_IMPORT_PLUGIN(qgif)

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QLabel label;
label.setPixmap(QPixmap("/usr/lib/ooo3/basis3.1/share/gallery/bigapple.gif"));
label.show();

qDebug() << QImageReader::supportedImageFormats();
return app.exec();
}


It works fine for me. Shows gifs (static build) and dumps gif as a supported format.

Are you sure you have the static gif plugins built at all?

stella1016
25th June 2010, 14:39
I've at least verified that it works for me. I used this pro file:



SOURCES += main.cpp
QTPLUGIN += qgif


And this source file:



#include <QtGui>
Q_IMPORT_PLUGIN(qgif)

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QLabel label;
label.setPixmap(QPixmap("/usr/lib/ooo3/basis3.1/share/gallery/bigapple.gif"));
label.show();

qDebug() << QImageReader::supportedImageFormats();
return app.exec();
}


It works fine for me. Shows gifs (static build) and dumps gif as a supported format.

Are you sure you have the static gif plugins built at all?

I have the similar problem. As long as I add the line "Q_IMPORT_PLUGIN(qgif)", there will be link error.

How did you set the first part in vs2008? And why does it need a static lib? Could you explain a little bit?