views:

1743

answers:

3

Hi! I'm learning to develop apps using Qt Creator. I have built a simple app under Windows, depends on uses mingwm10.dll, QtCore4.dll, QtGui4.dll, QtNetwork4.dll. Out of QtQui4.dll I use only a a couple of widgets, and don't need all of the rest... Is it possible to either shrink the size of QtGui4.dll or do something else to decrease deployment size of application? How about static linking? Will it embed the whole dll, or only parts of it that are used? And also is it possible with Qt to link some dlls staticly and some dynamicly?

+8  A: 

It's not possible to shrink the QtGui4.dll by removing some functions. Trolltech is having a look at this, but the good solution seems quite distant:

Static linking, I think it is very problematic on windows. Each time I tried, it was a nightmare.

So, it looks like you are stuck with the regular DLL. The only thing you can do (which I do for my Qt apps is):

  • use UPX to compress your DLL

or

  • use strong compression in your installer

If you already UPX your dll, you can not reduce it further with the installer compression, but this can reduce other files.

Bluebird75
Yea, "UPX -9 QtGui4.dll" is the way to go :)
corné
Interesting tip, I've never used UPX before.
20th Century Boy
Thank you! What is the smallest footprint of GUI Qt app you could archive this way?
Dmitri
+4  A: 

The best way is to manually configure the Qt library with configure. By issuing

configure --help

you'll see a number of options that might help reduce both disk and memory footprint. E.g.

--no-stl
--no-exceptions

can both reduce the footprint of your application. You can also modify the mkspec to use more aggressive optimization flags for your compiler.

Henrik Hartz
+1  A: 

If you link statically you end up with a 1.5GB exe and you sacrifice some functionality like plug-ins. So it's not really worth it unless you don't want to distribute the dlls. But yeah, you could try Henrik's suggestion and also exclude Webkit which is probably the biggest chunk of code.

20th Century Boy
In the context of the original question, excluding WebKit does not make any difference as he did not use it (only Core, Gui, Network modules).
Ariya Hidayat
Very good point.
20th Century Boy