View Full Version : Images not shown in static release exe (QT4.4.0, commercial, windows)

3rd September 2008, 14:04
Hello Mates!

for a long time i am searching for a solution concerning my problem - and i hope, that you can help me again.

i am using MS Visual Studio Professional 2005 with SP1 installed and QT4.4.0 Commercial + VS Studio integration. The project i am working on can be compiled without any problems as Debug within VS 05 on my development-machine (WinXP). A release can be build unfortunately only on the commandline (qmake -project, qmake -makefile, nmake) but without any errors. I am unable to compile the Project within VS - for some unknown reason there pop up about 80 linker errors. Well - the problem is as follows:
Debug - Exe: a QLabel can show Pixmaps
Release - Exe (compiled on commandline): a QLabel doesnt show ANY pictures!!! i dont know why! for some reason resources cannot be displayed or what... i dont know. Wherefrom are those milions of linker errors (in VS! not in Commandline! mysterious..)? is there a connection to the way of building QT statically perhaps?

i hope that description of my problem is understandable.

please help me!


3rd September 2008, 14:09
Did you link your application with any imageformat plugins?


3rd September 2008, 14:42
well, bardzo dziekuje za pomoc :) i followed the instructions on your page, really, thank you very much! but it does not work. now also on commandline i get those linker errors... do i have to recompile the qt as static library WITH explicit parameters for JPEG/GIF-Plugins? btw: bitmaps can be displayed properly.

thank you!

3rd September 2008, 14:53
well, bardzo dziekuje za pomoc :)
You are welcome.

now also on commandline i get those linker errors...
Could you post the exact error messages?

In order to make static JPEG and GIF plugins work, you need:
Qt built in static mode,
Q_IMPORT_PLUGIN(qjpeg) and Q_IMPORT_PLUGIN(qgif) macros in your sources,
QTPLUGIN += qjpeg qgif in the .pro file
Of course after changing the .pro file, you have to re-run qmake to get a new Makefile.

do i have to recompile the qt as static library WITH explicit parameters for JPEG/GIF-Plugins?
I don't remember. What files do you have in QTDIR/plugins/imageformats?

3rd September 2008, 15:08
the requested linker errors from commandline (yes, its german ;) )

moc_imagetest.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: static struct QMetaObject const QMainWindow::staticMetaObject" (?staticMetaObject@QMainWindow@@2UQMetaObject@@B)".
qtmain.lib(qtmain_win.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""private: static struct QByteArray:: Data QByteArray::shared_null" (?shared_null@QByteArray@@0UData@1@A)" in Funktion ""public: __thiscall QByteArray::QByteArray(void)" (??0QByteArray@@QAE@XZ)".
qtmain.lib(qtmain_win.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static enum QSysInfo::WinVersion const QSysInfo::WindowsVersion" (?WindowsVersion@QSysInfo@@2W4WinVersion@1@B)" in Funktion "_WinMain@16".
C:\imagetest\Release\imagetest.exe : fatal error LNK1120: 3 nicht aufgelöste externe Verweise.

qt is built statically with this command:
configure.exe -static -release
and following
nmake sub-src

and qmake -makefile was rerun after editing the .pro-file.

in the plugins-folder/imageformats are qjpeg.lib (300kb) and qjpeg4.lib (2kb) - it seems to be built statically...

edit: maybe that is interesting to know:
the application icon is not shown when the app is statically release-built on commandline. BUT: when i build it non-statical as release, the icon is shown and the picture can be loaded from harddisk. so: some libraries are not included obviously... but how to include them?

4th September 2008, 02:19
These particular error messages don't concern the plugins. Maybe your linker mixes static and non-static libraries? Did you had a non-static Qt built in the same directory?

4th September 2008, 12:21
indeed, qt static and qt dynamic were both in C:/Qt/
i removed the dynamic version. but: the dynamic-version-folder could not be deleted! some process accessed it obviously. so i just copied the files from static-folder to the dynamic one, in hope it works fine. but it doesnt.

i didnt post you those linker errors shown when i tried to compile with Q_IMPORT_PLUGIN etc. so ill do now:
WS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' ve
rsion='' publicKeyToken='6595b64144ccf1df' language='*' processorArchitec
ture='*'" /OUT:release\LTVKv2.exe @C:\DOKUME~1\LYTH\LOKALE~1\Temp\nm165.tmp
main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""class
QObject * __cdecl qt_plugin_instance_qjpeg(void)" (?qt_plugin_instance_qjpeg@@YA
PAVQObject@@XZ)" in Funktion ""public: __thiscall StaticqjpegPluginInstance::Sta
ticqjpegPluginInstance(void)" (??0StaticqjpegPluginInstance@@QAE@XZ)".
release\LTVKv2.exe : fatal error LNK1120: 1 nicht aufgelöste externe Verweise.
NMAKE : fatal error U1077: ""C:\Programme\Microsoft Visual Studio 8\VC\BIN\link.
EXE"": Rückgabe-Code "0x460"
NMAKE : fatal error U1077: ""C:\Programme\Microsoft Visual Studio 8\VC\BIN\nmake
.exe"": Rückgabe-Code "0x2"

thank you!

5th September 2008, 07:43
As far as I understand the error message, the linker can't find StaticqjpegPluginInstance::StaticqjpegPluginInstan ce symbol, which means that you are not linking your application with the static plugin.

Do you have CONFIG += static in your .pro file?

8th September 2008, 10:46
hey! thanks for helping me. it works quite fine now.

i followed your instructions and these ones from qt support:

1) download and compile the source packages of qt as static release with all plugins needed
2) copy it into a clean, fresh, new, virgin folder
3) set up library paths in VS
4) create vs-project with qmake -tp vc
5) compile project with plugin-macros described above :)