Remove unneeded classes ?
-
Hi all.
I (or rather we) are exploring the possibility of using Qt in Lua with binding.
I downloaded the Open Source version of Qt (under Linux) and configured the repository with
./init-repository --module-subset=essential
We only need the modules QtCore, QtGui and QtWidgets. Unfortunately the compiled libraries are large.
libQtCore.so.5.12.9 -- 72,5 MB libQtGui.so.5.12.9 -- 124,9 MB libQt5Widgets.so.5.12.9 -- 100,0 MB
We need to distribute these libraries with our Lua application but they are too large. We only need a subset of the classes available. My question is this:
Is there any way in the configuration/build process where it is possible to chose what classes one wants in the modules?
This primarily concerns the classes in QtWidgets but also the other two. The goal is to make the three libraries as small as possible while of course still maintaining the functionality of the classes we chose. I am not happy with just deleting source code, as this will likely break the build and is not a practical solution.
Thank you for all information.
-
@Rhett you may want to take a look at the Qt Lite approach.
See also this post for more information.
There's a Qt Configuration Tool but be aware that "To use the tool, you must have a commercial Qt license."
However, it seems to be an online tool which provides the settings needed depending on the modules selected.
-
For your information, I was now able to build far smaller libs.
export LLVM_INSTALL_DIR=/usr/lib/llvm-6.0 ../qt5/config.opt make module-qtbase
config.opt is
../qt5/configure \ -release \ -shared \ -opensource \ -confirm-license \ -optimize-size \ -ltcg \ -nomake examples \ -nomake tests \ -skip qtmultimedia \ -no-pch \ -no-feature-abstractbutton \ -no-feature-accessibility-atspi-bridge \ -no-feature-action \ -no-feature-alloca \ -no-feature-alloca_h \ -no-feature-alloca_malloc_h \ -no-feature-android-style-assets \ -no-feature-angle \ -no-feature-angle_d3d11_qdtd \ -no-feature-animation \ -no-feature-appstore-compliant \ -no-feature-avx2 \ -no-feature-big_codecs \ -no-feature-buttongroup \ -no-feature-c++11 \ -no-feature-c++14 \ -no-feature-c++1z \ -no-feature-c11 \ -no-feature-c99 \ -no-feature-calendarwidget \ -no-feature-checkbox \ -no-feature-clipboard \ -no-feature-clock-gettime \ -no-feature-colordialog \ -no-feature-colornames \ -no-feature-columnview \ -no-feature-combined-angle-lib \ -no-feature-combobox \ -no-feature-commandlineparser \ -no-feature-commandlinkbutton \ -no-feature-completer \ -no-feature-concurrent \ -no-feature-contextmenu \ -no-feature-cross_compile \ -no-feature-cssparser \ -no-feature-cursor \ -no-feature-cxx11_future \ -no-feature-datawidgetmapper \ -no-feature-datetimeedit \ -no-feature-datetimeparser \ -no-feature-dbus \ -no-feature-dbus-linked \ -no-feature-debug_and_release \ -no-feature-desktopservices \ -no-feature-dial \ -no-feature-dialog \ -no-feature-dialogbuttonbox \ -no-feature-direct2d \ -no-feature-direct2d1_1 \ -no-feature-direct3d11 \ -no-feature-direct3d11_1 \ -no-feature-direct3d9 \ -no-feature-directfb \ -no-feature-dirmodel \ -no-feature-dlopen \ -no-feature-dockwidget \ -no-feature-draganddrop \ -no-feature-drm_atomic \ -no-feature-dxgi \ -no-feature-dxgi1_2 \ -no-feature-dxguid \ -no-feature-effects \ -no-feature-egl \ -no-feature-egl_x11 \ -no-feature-eglfs \ -no-feature-eglfs_brcm \ -no-feature-eglfs_egldevice \ -no-feature-eglfs_gbm \ -no-feature-eglfs_mali \ -no-feature-eglfs_openwfd \ -no-feature-eglfs_rcar \ -no-feature-eglfs_viv \ -no-feature-eglfs_viv_wl \ -no-feature-eglfs_vsp2 \ -no-feature-eglfs_x11 \ -no-feature-errormessage \ -no-feature-etw \ -no-feature-evdev \ -no-feature-filedialog \ -no-feature-filesystemiterator \ -no-feature-filesystemmodel \ -no-feature-filesystemwatcher \ -no-feature-force_asserts \ -no-feature-formlayout \ -no-feature-framework \ -no-feature-fontcombobox \ -no-feature-fontconfig \ -no-feature-fontdialog \ -no-feature-fscompleter \ -no-feature-futimens \ -no-feature-futimes \ -no-feature-future \ -no-feature-gestures \ -no-feature-getauxval \ -no-feature-getentropy \ -no-feature-gif \ -no-feature-glib \ -no-feature-glibc \ -no-feature-gnu-libiconv \ -no-feature-graphicseffect \ -no-feature-graphicsview \ -no-feature-groupbox \ -no-feature-gtk3 \ -no-feature-harfbuzz \ -no-feature-ico \ -no-feature-iconv \ -no-feature-icu \ -no-feature-identityproxymodel \ -no-feature-im \ -no-feature-image_heuristic_mask \ -no-feature-image_text \ -no-feature-imageformat_bmp \ -no-feature-imageformat_ppm \ -no-feature-imageformat_xbm \ -no-feature-imageformat_xpm \ -no-feature-inotify \ -no-feature-inputdialog \ -no-feature-integrityfb \ -no-feature-integrityhid \ -no-feature-journald \ -no-feature-keysequenceedit \ -no-feature-kms \ -no-feature-lcdnumber \ -no-feature-libinput \ -no-feature-libinput-axis-api \ -no-feature-library \ -no-feature-libudev \ -no-feature-lineedit \ -no-feature-linkat \ -no-feature-linuxfb \ -no-feature-listview \ -no-feature-listwidget \ -no-feature-lttng \ -no-feature-mainwindow \ -no-feature-mdiarea \ -no-feature-messagebox \ -no-feature-mirclient \ -no-feature-movie \ -no-feature-mtdev \ -no-feature-multiprocess \ -no-feature-network \ -no-feature-opengl \ -no-feature-opengles2 \ -no-feature-opengles3 \ -no-feature-opengles31 \ -no-feature-opengles32 \ -no-feature-openvg \ -no-feature-paint_debug \ -no-feature-pdf \ -no-feature-picture \ -no-feature-pkg-config \ -no-feature-posix-libiconv \ -no-feature-posix_fallocate \ -no-feature-printer \ -no-feature-process \ -no-feature-processenvironment \ -no-feature-progressbar \ -no-feature-progressdialog \ -no-feature-qeventtransition \ -no-feature-qml-animation \ -no-feature-qml-debug \ -no-feature-qml-delegate-model \ -no-feature-qml-devtools \ -no-feature-qml-list-model \ -no-feature-qml-locale \ -no-feature-qml-network \ -no-feature-qml-preview \ -no-feature-qml-profiler \ -no-feature-qml-sequence-object \ -no-feature-qml-worker-script \ -no-feature-qml-xml-http-request \ -no-feature-quick-canvas \ -no-feature-quick-designer \ -no-feature-quick-flipable \ -no-feature-quick-gridview \ -no-feature-quick-listview \ -no-feature-quick-particles \ -no-feature-quick-path \ -no-feature-quick-pathview \ -no-feature-quick-positioners \ -no-feature-quick-repeater \ -no-feature-quick-shadereffect \ -no-feature-quick-sprite \ -no-feature-quick-tableview \ -no-feature-radiobutton \ -no-feature-reduce_exports \ -no-feature-reduce_relocations \ -no-feature-release_tools \ -no-feature-renameat2 \ -no-feature-resizehandler \ -no-feature-rpath \ -no-feature-rubberband \ -no-feature-scroller \ -no-feature-separate_debug_info \ -no-feature-sessionmanager \ -no-feature-settings \ -no-feature-sha3-fast \ -no-feature-sharedmemory \ -no-feature-shortcut \ -no-feature-simulator_and_device \ -no-feature-sizegrip \ -no-feature-slog2 \ -no-feature-sortfilterproxymodel \ -no-feature-spinbox \ -no-feature-splashscreen \ -no-feature-splitter \ -no-feature-sql \ -no-feature-sql-sqlite \ -no-feature-stack-protector-strong \ -no-feature-standarditemmodel \ -no-feature-statemachine \ -no-feature-statusbar \ -no-feature-statustip \ -no-feature-statx \ -no-feature-style-android \ -no-feature-style-fusion \ -no-feature-style-mac \ -no-feature-style-stylesheet \ -no-feature-style-windows \ -no-feature-style-windowsvista \ -no-feature-syntaxhighlighter \ -no-feature-syslog \ -no-feature-system-doubleconversion \ -no-feature-system-freetype \ -no-feature-system-harfbuzz \ -no-feature-system-pcre2 \ -no-feature-system-png \ -no-feature-system-zlib \ -no-feature-systemsemaphore \ -no-feature-systemtrayicon \ -no-feature-tabletevent \ -no-feature-tableview \ -no-feature-tablewidget \ -no-feature-testlib \ -no-feature-textbrowser \ -no-feature-textedit \ -no-feature-texthtmlparser \ -no-feature-textodfwriter \ -no-feature-texture_format_astc_experimental \ -no-feature-timezone \ -no-feature-toolbox \ -no-feature-tooltip \ -no-feature-topleveldomain \ -no-feature-translation \ -no-feature-treeview \ -no-feature-treewidget \ -no-feature-tslib \ -no-feature-tuiotouch \ -no-feature-undocommand \ -no-feature-undogroup \ -no-feature-undostack \ -no-feature-undoview \ -no-feature-validator \ -no-feature-vnc \ -no-feature-vsp2 \ -no-feature-vulkan \ -no-feature-whatsthis \ -no-feature-wheelevent \ -no-feature-wizard \ -no-feature-xcb-xinput \ -no-feature-xlib \ -no-feature-xml \ -no-feature-xmlstreamwriter \ -xcb \ -feature-xlib \ -feature-xcb-xlib \ -feature-jpeg
This file will very likely have to be tweaked, but that will not change the size of the libs very much. The sizes now are:
libQt5Core.so.5.12.9 --- 4,5 MB libQt5Gui.so.5.12.9 --- 3,9 MB libQt5Widgets.so.5.12.9 --- 1,9 MB
-
libQtCore.so.5.12.9 -- 72,5 MB libQtGui.so.5.12.9 -- 124,9 MB libQt5Widgets.so.5.12.9 -- 100,0 MB
->
libQt5Core.so.5.12.9 --- 4,5 MB libQt5Gui.so.5.12.9 --- 3,9 MB libQt5Widgets.so.5.12.9 --- 1,9 MB
Wow!! 300MB -> 10MB! Just OOI, do you know whether one particular area saved most of the size, or was it distributed all over the place? Since you have excluded 97%, what have you actually left in from Qt?
-
Hello.
You basically see what is left by what is not excluded.
I do not rule out that we will need a few more features, f.ex. mainwindow, but the GUI we need is really simple, therefore not many widgets. We need to paint on the screen and we need to scale and rotate images. I guess we also need to remove more features, i.e. we don't need network at all.
Anyone who wants to work further with their own config.opt, be aware that you can easily break the build. At least the config.opt above actually builds.