Static build - size of exe too big



  • Hi,

    we are statically building our executables since we mainly want to use the uniform GUI.
    Problem is though that the executable is way too big (approx. 15MB), compared to the actual program (~ 1MB) we want to run.
    Is there any way to reduce the size of the .exe files, essentially loading only those components which are necessary for the GUI to be displayed correctly?

    Many thanks and best regards,
    Christos


  • Qt Champions 2016

    @christos.alewa
    Hello,

    we are statically building our executables since we mainly want to use the uniform GUI.

    This doesn't constitute a great reasoning for static building in my opinion. Are you sure static linking is what you want (or need)?

    Is there any way to reduce the size of the .exe files, essentially loading only those components which are necessary for the GUI to be displayed correctly?

    My best advice for that question would be - you could build and link dynamically instead of static.
    The second best - strip all symbols and resources from the executable.

    If you provide a bit more on your use case it might attract some better answers.

    Kind regards.



  • @kshegunov
    Hi and thanks for your quick answer.

    Since we want to start the GUI over the web, it would be much more helpful if it was just one, small, statically linked, file.
    That would be executed - provide the GUI - and then, if necessary, start & download our tool.
    To your second advice, that is probably the true answer i was looking for, but how can i strip all symbols and resources from the executable?

    Thanks again.


  • Qt Champions 2016

    @christos.alewa

    Hello,
    Here's a way to do it with g++, but note that this is platform-dependent, so I have no idea if it's even possible with MS's compiler or on OSX.
    As a side note 15MB is a bit big for a release build, even with static linking. What Qt modules do you include in that? If possible strip out as much as you can in terms of libraries and code.

    Kind regards.


  • Lifetime Qt Champion

    Hi,

    Out of curiosity, what do you mean by "start the GUI over the web" ?



  • @SGaist
    Essentially, download the executable and run it.
    That's why size is an issue.


  • Lifetime Qt Champion

    What modules are you using for your application ?



  • @SGaist
    QCore, QGUI & QWidget..


  • Lifetime Qt Champion

    From the server side you should send your files as compressed data.

    On the Qt side, since you are building Qt yourself anyway, you can try disabling features your application don't need. See the qfeatures.txt file for what you can disable.

    On a side note, don't forget the licensing constraints that comes with a static build of Qt.



  • @SGaist
    It seems that it is indeed, already optimized, since we did disable many features, until it could not be build anymore - but we're still facing the same sized executable.

    Thank you, though, maybe we'll figure it out eventually.



  • You could certainly make use of UPX, it should get the filesize down to maybe 4MB (by using compression).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.