hopeless_nerd
hopeless_nerd

Reputation: 51

Qt - How to reduce the "bundled" size?

I decided to try programming with Qt since I wanted to make a GUI application in the language my application is natively written in. I downloaded Qt, watched a few tutorials, and made a simple Hello World application. When I tried to show my friend, however, he was complaining about missing DLLs. Fast foward and eventually I ended up finding a tool that automatically included all of the dependencies that Qt needed to function.

So my question:

enter image description here

Do I really need to include all of this when I distribute my application? Is this the price I pay for not using C# and calling my application's functions through a DLL? The actual application I'm writing only compiles to about 100kb, do I really need to include over 44x that in dependencies?

Upvotes: 1

Views: 858

Answers (2)

László Papp
László Papp

Reputation: 53155

Yes, in short, your observation is correct. Qt is not the smallest framework possible for GUI purposes.

Even the QtCore library is getting 4-5 MB these days, let alone the rest like QtGUI, especially if you use QtWidgets, etc.

If you are really into something smaller, you can look for alternatives frameworks that are smaller. I personally prefer fltk, although I had to adjust it to my needs to be usable with framebuffers. That is probably not on your radar, though.

One thing that you could also look into is the feature system established in Qt. That means you can turn features off that you are not planning to use. The disclaimer goes that you are on your own should you decide to go down that way.

Some people think that static linking will gain you much, too. I have experimented with that quite a bit in the past, but while it had not come with huge improvements, it did come with these drawbacks:

  • You need to redeploy your application whenever you would like to update Qt. This is not a corner case, obviously, since it is nice to get bug fixes, just for one of those.

  • Even if you gain a small bit of size improvement, you will lose that when you start deploying multiple Qt applications.

  • You can easily get into legal troubles with that, especially if you are writing proprietary software, which is again not corner case.

  • It is not that straight-forward to link statically under all circumstances.

Therefore, it is better to use the feature system established for this very purpose in Qt.

Having said that, there are even bigger frameworks for this purpose just to scare you off a bit. Still, Qt is not something that you will put onto a 8 bit microcontroller with very limited flash and ram.

So my advice is either get used to the status quo or escape.

Upvotes: 0

Klathzazt
Klathzazt

Reputation: 2454

You can compile Qt statically, then when you link against the static libraries your resulting execurable will both be:

  • self contained, no need for dll's
  • much smaller

Compiling Qt statically takes a long time. You also have to consider the license for Qt if you statically link if for commercial purposes.

Upvotes: 2

Related Questions