PDA

View Full Version : Exporting with libraries.



Rewo
30th June 2010, 20:34
Hi, it's me again.

I've just wrote an application in QT (4.6.2 + Creator 1.3.1).

I've got problem with libraries. If I want to execute compiled .exe file manually, application needs:

- mingwm10.dll
- libgcc_s_dw2-1.dll
- QtCored4.dll
- QtGuid4.dll

These 4 files are 189 MB size overall.

How to make this program working with less quantity of libraries (I mean size of them) ?

First lines of source's files:

mainwindow.h


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "ui_mainwindow.h"

main.cpp


#include <QtGui/QApplication>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTextCodec>

mainwindow.cpp


#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QInputDialog>
#include <QMessageBox>

I guess that <QtGui/QApplication> makes problem.

Zlatomir
30th June 2010, 20:50
You have no problem...

Those are the Debug versions of dll's (they are bigger because they contain much more debugging information and they are don't contain optimizations)

Solution: Select the RELEASE configuration in the build menu
and use:
- QtCore4.dll (the ones without 'd' letter)
- QtGui4.dll
They will have about ~15 MB ;)

and.andrade
30th June 2010, 20:52
Have you build QT with the -static option activated?

Edit:
I thought it could be related to that (static linking)
Anyone could say then
if when we use static linking the final .exe is bigger?
because the libraries are put together..

Zlatomir
30th June 2010, 20:57
Have you build QT with the -static option activated?

I'm trying to better understand it, but when you use static linking I think your .exe tends to be bigger,
because the libraries are put together..
No, the .dll files are bigger, not the .exe.

He needs to build the release version of he's application, and use the release version of dll's (they are much smaller)

Rewo
30th June 2010, 21:03
You have no problem...

Those are the Debug versions of dll's (they are bigger because they contain much more debugging information and they are don't contain optimizations)

Solution: Select the RELEASE configuration in the build menu
and use:
- QtCore4.dll (the ones without 'd' letter)
- QtGui4.dll
They will have about ~15 MB ;)

It's really working ! Thank You very much :)

and.andrade
30th June 2010, 21:04
Oh yes, you are right. Thanks !
I was talking about the wrong subject.

Talei
30th June 2010, 22:20
You can use UPX program to "shrink" any executables like dll, exe, so and so one. Works with Win and Linux binaries, great program. In release mode, after UPX'ing, program + dll have size of 5MB, depending on the used classes.

Zlatomir
30th June 2010, 22:36
@Talei, thanks
That sounds good, but i have a question: have you tested enough? Because if it introduce new "bugs", it's not worth it!
Or it just compresses the size of exe/dll on the HDD, and decompresses it in the RAM?

Sorry for stupid question, but i didn't had time to search how that works!

Talei
30th June 2010, 22:48
Well I don't really need to test it because UPX is around for some time right now. Also there is decompress parameter that can, obviously, decompress binaries, so if something goes wrong You know about that. I use it from 2008, with my Qt project also without any problems. Basically it, depending on the parameters, compress binaries (You can chose compression lvl), strip. Only drawback is that programs load little longer (but it depends on the compression level and CPU speed. I saw difference on my old Celeron 1.2Ghz laptop, load was longer but not so much as I would expect on file with compression ratio 45-60%.)
For more details check homepage http://upx.sourceforge.net/ .

Rewo
1st July 2010, 10:21
I'll try it in my free time.

EDIT:

It's very interesting, size of files is about 33%-40% ratio. We will see after packing into *.rar.

EDIT2:

So.

Without using UPX:

libgcc_s_dw2-1.dll + mingwm10.dll + QtCore4.dll + QtGui4.dll + mobile.exe -> packed into rar : 3983 KB
libgcc_s_dw2-1.dll + mingwm10.dll + QtCore4.dll + QtGui4.dll + mobile.exe -> unpacked : 11840 KB
RAM usage : 7500 KB

With use of UPX:

libgcc_s_dw2-1.dll + mingwm10.dll + QtCore4.dll + QtGui4.dll + mobile.exe -> packed into rar : 3969 KB
libgcc_s_dw2-1.dll + mingwm10.dll + QtCore4.dll + QtGui4.dll + mobile.exe -> unpacked : 4644 KB
RAM usage : 16652 KB

It's very useful.

Talei
1st July 2010, 12:00
Also using UPX serves as "protection" against debuggers. I remember, back in my school days, when I came across UPX'ed exe (wanted to change some values in exe)... it was a long way to figure out what was what, for the person with very little programming exp. at that time. Said that, the person who will want to crack Your code will do that, I mean... they crack Themida so....
Right now I think UPX is one of this tool that You "must to have", and not only for the Qt.