[Qt-interest] Trying to use ICO icons in a dll linked to static QT 4.5.3

Yuvraaj Kelkar yuvraaj at gmail.com
Thu Oct 29 15:22:09 CET 2009


Yuvraaj Kelkar wrote:
> Hi all,
>
> I have created a DLL that links statically to QT 4.5.3
> This DLL has 3 .ico files compiled into it using a qrc.
> I have already compiled QT statically.
>
> Initializing the QIcon does not show any errors, enumerating the 
> resource contents using QDir shows that my ico files exist and are 
> accessible.
> When I actually showing those icons - in my case in the system tray 
> using QSystemTrayIcon - no icon is displayed.
>
> QSystemTrayIcon itself works - I can click, right click, hover over 
> the "blank space" created by the class in the tray. It just cannot 
> show an icon.
>
> I debug stepped into the QSystemTrayIcon::setIcon to see what the 
> problem was. Turns out that there is no ICO pixmap handler.
> I guess that this is because the ico plugin has not been loaded / 
> compiled into my dll.
>
> So I tried loading the qico plugin as explained in:
> http://doc.trolltech.com/4.5/qtplugin.html#Q_IMPORT_PLUGIN
> http://doc.trolltech.com/4.5/plugins-howto.html#static-plugins
>
> In my .pro:
> static {
>     QTPLUGIN += qico
>     DEFINES += STATIC
>     message("Static build")
> }
>
> and in my source file:
> #ifdef STATIC
> #include <QtPlugin>
> Q_IMPORT_PLUGIN(qico)
> #endif
>
> With this I get link errors:
>         link /LIBPATH:"c:\qt\lib" /NOLOGO /DEBUG /DLL /MANIFEST 
> /MANIFESTFILE:"debug\zcmn.intermediate.manifest" /OUT:debug\mydll.dll 
> @C:\DOCUME~1\Uv\LOCALS~1\Temp\nm2696.tmp
> LINK : fatal error LNK1104: cannot open file 'qicod.lib'
>
> I looked into my qt folder for a lib file called qico.lib and 
> qicod.lib: Neither was present.
> I looked into \qt\src\plugins\imageformats\ico\tmp\obj\ and found the 
> debug_static and release_static folders with qicohandler.obj compiled 
> in both.
>
> This is the command I used to configure QT to build statically:
> .\configure.exe -debug-and-release -static -no-fast -no-exceptions 
> -accessibility -no-stl -plugin-sql-sqlite -no-qt3support -no-opengl 
> -platform win32-msvc2008 -graphicssystem raster -no-incredibuild-xge 
> -plugin-manifests -qmake -process -no-rtti -3dnow -sse -no-openssl 
> -dbus -no-phonon -no-phonon-backend -no-webkit -no-scripttools -arch 
> windows -no-style-motif -no-style-cde -no-style-cleanlooks 
> -no-style-plastique -nomake examples -nomake demos
>
> Followed by:
> nmake sub-src
>
> I've Googled for the last one week looking for an answer. Any help 
> would be appreciated. Anything - even moral support!
>
> Thanks,
> Uv
>
Hi all,
I know its bad form to reply to my own post, but this is something I 
must do so that the next bloke who comes with sort of a problem knows 
how to fix it:

1. In your .pro file:
static {
     QTPLUGIN += qico
     DEFINES += STATIC
     message("Static build")
     LIBS += -L$$[QT_INSTALL_PREFIX]/plugins/imageformats
}

Note the added library path.

2. In your sources file:
#ifdef STATIC
#include <QtPlugin>
Q_IMPORT_PLUGIN(qico)
#endif

3. On the command line:
make distclean ; qmake ; make all

4. Run and bask in the heavenly feeling of working code!




More information about the Qt-interest-old mailing list