Results 1 to 3 of 3

Thread: Minimal size of a statically-linked Qt application

  1. #1

    Default Minimal size of a statically-linked Qt application

    Hello.

    What's the best way to reduce the size of a statically-linked Qt executable? I've configured my Qt build using:

    configure -release -static -opensource -confirm-license -platform win32-g++ -nomake examples -nomake demos -no-ltcg -no-exceptions -no-accessibility -no-sql-mysql -no-sql-psql -no-sql-oci -no-sql-odbc -no-sql-tds -no-sql-db2 -no-sql-sqlite -no-sql-sqlite2 -no-sql-ibase -no-qt3support -no-opengl -no-openvg -no-gif -no-libpng -no-libpng -no-libmng -no-libtiff -no-libjpeg -no-dsp -no-vcproj -no-incredibuild-xge -no-plugin-manifests -no-plugin-manifests -no-rtti -no-mmx -no-3dnow -no-sse -no-sse2 -no-openssl -no-dbus -no-phonon -no-phonon-backend -no-multimedia -no-audio-backend -no-webkit -no-script -no-scripttools -no-declarative -no-declarative-debug -no-style-plastique -no-style-cleanlooks -no-style-motif -no-style-cde -no-style-windowsce -no-style-windowsmobile -no-style-s60 -no-mp -no-iwmmxt -no-crt -no-cetest -no-freetype -no-s60 -no-usedeffiles -no-native-gestures
    This configuration basically includes all of the -no-??? directives apart from -no-stl and -no-qmake and. A simple Qt widget application still takes about 7-8 MBs. Is there any way to reduce it's size even more (besides packers like UPX)?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Minimal size of a statically-linked Qt application

    I don't think you can expect a file of 1 MB.
    Around 7 or 8 MB sounds about ok.

    There are tools, like you mention, who can reduce the size even more by stripping out unneeded symbols and compress data.

    If size is an issue, perhaps a static file is not the best solution.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Minimal size of a statically-linked Qt application

    I doubt that -any- of the -no-??? directives are actually necessary, since static linking should pull in only the dependencies you are actually using and nothing more. So if your program (and nothing that your program uses from inside Qt) is using any of the SQL drivers for example, none of the code to support them will be linked in whether you specify it on the command line or not.

    It looks like most of the options you've included are intended to configure building the Qt libraries themselves, not for building applications based on Qt and would be ignored anyway.

    I think you have to expect that as soon as you start including any graphical features at all (i.e. QApplication / QWidget) and statically link to Qt, the size of your executable will be much bigger than a console-only app based on QCoreApplication.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. error loading statically linked Qt app
    By nitingeorge in forum Installation and Deployment
    Replies: 1
    Last Post: 30th May 2011, 08:11
  2. Replies: 2
    Last Post: 5th March 2010, 09:26
  3. Application seems not to be linked statically
    By Boron in forum Installation and Deployment
    Replies: 5
    Last Post: 2nd April 2008, 17:14
  4. Statically linked QtSql modules
    By runderwo in forum Qt Programming
    Replies: 5
    Last Post: 10th September 2007, 22:43
  5. statically linked executable
    By smalls in forum Qt Programming
    Replies: 8
    Last Post: 11th February 2006, 02:09

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.