Qt doesn't display Jpg and Gif files in release built on Windows

This reading is also for you if your build fails and the linker output says


cannot find -lqjpeg" or "cannot find -lqgif

If your application is dynamically linked to Qt library then all you have to do is to include qjpeg4.dll and qgif4.dll to the folder where the application is going to be started in. Those files can be found in folder c:\qt\2009.03\qt\plugins\imageformats (replace with your actual qt folder where necessary)

If however your application is build with static link to Qt library then these Qt plugins also have to be linked statically. See this post on this blog for information on how to create a static build of Qt library on Windows OS.

First enter this in your main.cpp:


Q_IMPORT_PLUGIN(qjpeg);
Q_IMPORT_PLUGIN(qgif);

Then this in your .pro file:


QTPLUGIN += qjpeg qgif

And rebuild.


Previous: Two separate classes that need each other
Next: Build application linked with static Qt library in Windows