Let’s build small Qt libraries! (Step 2: Optimize build-settings)
Page |
1 |
I want to slim down my Qt-libraries a bit.
Therefore I downloaded the lateest source-package (qt-everywhere-opensource-src-4.7.3.tar.gz).
The first thing I wanted to do is build qconfig.exe
Therefore I run:
- Configure -release -opensource -no-exceptions -no-stl -no-opengl -no-openvg -no-libjpeg -no-libtiff -no-dsp -no-vcproj -no-webkit -no-scripttools -no-native-gestures
I have three questions for now:
1. qconfig can’t find X11-related stuff. May I have excluded that when building the first time?
2. I’ve read about some useful gcc switches to reduce the size of the libraries
-Os
-fmerge-all-constants
-fno-default-inline
-fno-inline
The instruction was to put them in the qmakespec-file. Where do I find that?
3. What does the switch -L mean when running configure? I’ve seen it a bunch of times
35 replies
1. Use UPX for binaries UPX [upx.sourceforge.net]
3. It means probably a library -lmath, -luser32, -lkernel32 etc…
hi,
i noticed upx not support PE+ or win64, might use mpress http://www.matcode.com/mpress.htm
it work like a charm.. :)
I’ve already programmed this tool twice (in Object Pascal and C#). The tool was always around 2-3 MB in size.
I don’t want to scare my users off and am generally interested in this whole build-improvement thing.
Binding it statically won’t reduce the size much (and isn’t allowed in that context either if I go LGPGL).
@Peppy: I will try the MSVC-compiler as well.
As you’re on Windows using MinGW (I know your project quite good now :-) ) you must add the respective mkspec:
- ./configure -platform win32-gcc ... your additional args go here ....
The rest of your no-xxx switches does not influence the size very significantly. It just leaves out the build of some submodules and the like, which you would not put into your final applications directory anyways.
Be sure to create release libs (without debugging symbols), this decreases the size of the libs significantly!
And finally you can try to run MinGW/bin/strip.exe on every executable and library (DLL) you have in your directory. I did not try this yet, but at least on Unix this reduces the size even more.
For distribution, put it all in a ZIP. UPX and the like is not really useful IMHO. The exe and the libs must be decompressed eventually to run the program, thus slowing down the start up time of your application.
Remember: Disk space is cheap :-)
@Volker: I thought so. But I am very surpised that somebody wants to compress binaries on the maximum in time when we have 2-3 TBytes harddisks (no everybody has terabytes harddrives, but 16MB is not so much…)…
I am compiling under MSVC 2008 compiler and it’s quite better than MinGW (IMHO)…
BTW. What is the name of your project? :-)
As you’re on Windows using MinGW (I know your project quite good now :-) ) you must add the respective mkspec:
./configure -platform win32-gcc … your additional args go here ….
Just making sure. So I need to attach the compiler-switches like -fmerge-all-constants already in the configure-step?
These are the Qt-dll’s and their sizes my program currently needs:
- Uncompressed size | UPX -9 size | Name
- ---------------------------------------------------
- 2,43MB | 0,91MB | QTCore4.dll
- 2,92MB | 0,86MB | QTDeclarative4.dll
- 9,39MB | 3,69MB | QtGui4.dll
- 1,15MB | 0,40MB | QTNetwork4.dll
- 2,07MB | 0,65MB | QTScript4.dll
- 0,20MB | 0,10MB | QTSql4.dll
- 3,82MB | 0,94MB | QTXmlPatterns4.dll
- ---------------------------------------------------
- 21,98MB 7,55MB
Especially QtGui4.dll should be reducable much further since I’m using exclusively QML (with Jens desktop-components) for the GUI.
You must log in to post a reply. Not a member yet? Register here!


