Question

I am looking for a way to create a minimal static build of Qt 5.1. By minimal, I mean a build with only the basic set of widget classes available (including 2D graphics acceleration through an OpenGL canvas/widget). I am aiming for a static build on Windows 7 32-bit using MinGW-builds GCC 4.8.1 as well as their bundle of MSYS and tools.

I have downloaded the entire source tree, and have met some problems with compiling due to the dependency of packages such as OpenSSL and ICU (the latest OpenSSL did not compile). I wanted to see, if I could avoid dependencies of these packages and, at the same time, achieve a minimal static build of Qt 5.1 so my final executable is not gigantic in size.

I took a look at this list: http://download.qt-project.org/official_releases/qt/5.1/5.1.0/submodules/.

Q1: Which of these modules, do I need to select to have a basic Qt build without all the fancy stuff?

Q2: Are these modules interdependent on each other in some way (I assume they are all dependent on "qtbase")?

Q3: Do I use the names from that list, (for example: "qtxmlpatterns", "qtx11extras", "qtwebkit", etc.), to deselect them in the configuration of my Qt build?

It would also be nice, with an explanation of the various submodules of Qt 5? If someone could point to any links or docs with illuminating words on this subject, that would also be great.

Was it helpful?

Solution

I shared this same goal. I wanted to "minify" Qt, building only a small subset of the libraries/DLL(s) and omitting the rest.

I did succeed, at least on Mac OS X. I assume that this approach will work on other platforms, too.

I thought that the trick would be to find some kind of exclusion flags for the "configure" script, but that turned out not to be the case.

Here is what I did:

  1. Download the source distribution (in my case, qt-everywhere-opensource-src-5.1.1). of course, extract it all.

  2. Edit the following three "pro" files. these files are in a qt-specific format (but plain text). They are platform-independent project files that Qt (via qmake) uses to generate makefiles.

    • qtbase/src/src.pro
    • qtbase/src/plugins/plugins.pro
    • qtbase/examples/examples.pro

All the changes that I made to the "pro" files were deletions. I deleted references to: dbus, ipc, network, qtconcurrent, sql, xml, sqldrivers, qdbusxml2cpp, qdbuscpp2xml, src_dbus, src_concurrent, src_sql, src_network.

That last part may sound scary. It really wasn't.

The pro files contain a list of module names, plugin names, and directory names. It seemed fairly straightforward how to delete (for example) all SQL-related lines.

Step 3.

The usual configure/make/install. However, note the "module-qtbase" argument passed to make:

./configure -prefix ~/my_test_dir/
make -j2 module-qtbase
make -j2 module-qtbase-install_subtargets

Success. This built and installed only the essentials (QtCore, QtGui, QtOpenGL, QtWidgets) and skipped all the supporting dylibs like QtConcurrent, QtMultimedia, QtSql, and QtWebKit.

OTHER TIPS

ICU can link statically, and you can customize it (see docs) to reduce size. By default the data is also large, I don't know how much data you need. You could include only enough data to run in one language.

Only part of an answer.

There's no need to disable Qt modules. Each application that uses Qt decides what modules it uses and links with. A basic console-only application may use the core module only. That's what you'd use when creating, say, a web service in Qt.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top