Results 1 to 11 of 11

Thread: Exporting with libraries.

  1. #1
    Join Date
    Apr 2010
    Posts
    19
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Exporting with libraries.

    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

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include "ui_mainwindow.h"
    To copy to clipboard, switch view to plain text mode 

    main.cpp

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3. #include "ui_mainwindow.h"
    4. #include <QTextCodec>
    To copy to clipboard, switch view to plain text mode 

    mainwindow.cpp

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include <QInputDialog>
    4. #include <QMessageBox>
    To copy to clipboard, switch view to plain text mode 

    I guess that <QtGui/QApplication> makes problem.

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Exporting with libraries.

    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

  3. The following user says thank you to Zlatomir for this useful post:

    Rewo (30th June 2010)

  4. #3
    Join Date
    Jun 2010
    Location
    Brazil
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Exporting with libraries.

    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..

  5. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Exporting with libraries.

    Quote Originally Posted by and.andrade View Post
    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)

  6. #5
    Join Date
    Apr 2010
    Posts
    19
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Exporting with libraries.

    Quote Originally Posted by Zlatomir View Post
    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

  7. #6
    Join Date
    Jun 2010
    Location
    Brazil
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Exporting with libraries.

    Oh yes, you are right. Thanks !
    I was talking about the wrong subject.

  8. #7
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Exporting with libraries.

    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.

  9. The following user says thank you to Talei for this useful post:

    Zlatomir (30th June 2010)

  10. #8
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Exporting with libraries.

    @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!

  11. #9
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Exporting with libraries.

    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/ .

  12. #10
    Join Date
    Apr 2010
    Posts
    19
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Exporting with libraries.

    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.
    Last edited by Rewo; 1st July 2010 at 11:03.

  13. #11
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Exporting with libraries.

    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.

  14. The following user says thank you to Talei for this useful post:

    Rewo (1st July 2010)

Similar Threads

  1. Exporting to RTF
    By gruszczy in forum Qt Programming
    Replies: 2
    Last Post: 19th February 2009, 00:00
  2. Symbol Exporting in dylib
    By nareshqt in forum Qt Programming
    Replies: 1
    Last Post: 21st July 2008, 03:36
  3. creating and exporting .dll
    By hrcariaga in forum Qt Programming
    Replies: 2
    Last Post: 7th February 2008, 09:45
  4. DLL exporting functions, variables, class
    By Shuchi Agrawal in forum Newbie
    Replies: 1
    Last Post: 25th April 2007, 11:40
  5. Qt 3.3 libraries
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 21st December 2006, 17:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.