Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to reduce Qt Application Binary size ?



  • Hi All,

    I have compiled Qt for Embedded Linux platform statically.
    I have also used qconfig to remove some of the functionality to reduce the size of the Qt Binary.
    But i haven't gain much size difference between above changes.
    Currently my Qt Application size id ~8MB after the some changes i got ~214KB size reduction BUT is there any way i can reduce the size my Qt Application to ~5MB ? Any change in configure command ? I have given following configuration command for embedded linux.

    /home/Qt_lib_optimization/QTOMAP_Optimize/Source/qt-everywhere-commercial-src-4.6.0/configure -prefix /home/Qt_lib_optimization/QTOMAP_Optimize/Install -embedded arm -static -depths 24 -qt-kbd-linuxinput -no-largefile -stl -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-sqlite_symbian -no-sql-tds -no-qt3support -no-phonon -no-webkit -no-gif -no-libtiff -no-libmng -qt-libpng -qt-libjpeg -no-dbus -no-nis -no-openssl -no-scripttools -no-javascript-jit -no-mmx -no-3dnow -no-sse -no-sse2 -little-endian -v -xplatform qws/linux-arm-g++ -host-little-endian -nomake examples -nomake demos -nomake docs -nomake translations -no-xrender -no-xrandr -no-xfixes -no-xcursor -no-nas-sound -no-opengl -no-openvg -no-sm -no-xshape -no-xinerama -no-javascript-jit -no-multimedia -qconfig 10May2011

    Give me some idea to reduce the size of my Qt Application.
    How can i achieve size reduction ?

    Thanks,
    Neel



  • Maybe there's a linker option that makes sure only code that is actually used is included. Else you will have to remove everything and add certain components until your application can be built again.



  • which linker option to set ?...
    Another way to reduce the size ?



  • [quote author="neel2818" date="1305105920"]which linker option to set ?...[/quote]Don't know about that.



  • There is also the choice to compress the binary. Look at "upx":http://upx.sourceforge.net/ , it could be available also in linux repositories



  • Some time ago I heard about that compiler option: gcc has the ability to search for functions that call other functions that... (etc), but skipping those other included in the same file but never called.

    I remember finding this option in man gcc, and being unable to finally use it... Maybe the links below offer some help.

    http://www.google.es/search?q=partial+linking&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:es-ES:official&client=firefox-a

    http://stackoverflow.com/questions/270984/g-partial-linking-instead-of-archives

    http://newsgroups.derkeiler.com/Archive/Comp/comp.compilers/2005-07/msg00131.html

    (...) something along the lines ld -Ur -o mylib.o [components] (...)

    --



  • "Building Qt Static (and Dynamic) and Making it Small with GCC, Microsoft Visual Studio, and the Intel Compiler":http://www.formortals.com/build-qt-static-small-microsoft-intel-gcc-compiler/



  • If you want to use static builds, make sure you use the correct license options.
    Afaik (I'm not a lawyer!) you have to have a commercial license or your software must be GPL to use static linking.



  • IANAL either, but AFAIK, as long as you provide the option to re-link against another version of the library, you are allowed to use static linking using the LGPL Qt libraries. And no, that is probably not too easy to do, but I think Gerolf's comment is incorrect.


Log in to reply