BladeMight
BladeMight

Reputation: 2810

Why Qt is making developers to include their dlls for every application?

I noticed that deployed on windows Qt applications are always including the dlls they needed. Why did they made it that way? Why can't they do it like on linux? - You install needed Qt version to system, and then every application that need it - can use it, e.g. only one instance of libraries(excluding different versions like qt4/qt5).

Wouldn't it be better to make it like Java/.Net, e.g. you install Java/.Net then you run/develop applications using only one instance of libraries(dlls).

I find it kinda "unconservating": I have 7 applications that use Qt5, and all of them have Qt5Core.dll, Qt5GUI.dll, etc. and every of them takes some space. Feels like I have 7 packs of Qt5 libraries... x_x

While on linux these same applications use only "one" Qt library.

Upvotes: 2

Views: 250

Answers (1)

JKSH
JKSH

Reputation: 2718

I noticed that deployed on windows Qt applications are always including the dlls they needed.

This is called "local deployment".

Why did they made it that way?

I can think of a few reasons.

  1. To avoid DLL Hell.
  2. It is sanctioned by Microsoft. They wrote, "You can use this deployment method to enable installation by users who don't have administrator rights, or for applications that can be run from a network share." (see https://learn.microsoft.com/en-us/cpp/windows/choosing-a-deployment-method?view=vs-2019)

You install needed Qt version to system, and then every application that need it - can use it, e.g. only one instance of libraries(excluding different versions like qt4/qt5)

Qt is a C++ library. C++ DLLs can differ by more than just a major version number. The DLLs could be built with MinGW, or they could be built with MSVC; They could be 32-bit, or they could be 64-bit. The different variants are incompatible with each other.

Example: if you force a PC to have one global copy of Qt 5.14.1 MSVC 32-bit and put that in your PATH, then:

  • Other Qt apps on that PC that are built with MinGW cannot run.
  • Other Qt apps on that PC that are 64-bit cannot run.
  • Apps that must use Qt 5.13 might be broken. (For example, if a critical bug exists in Qt 5.14)

Why can't they do it like on linux? .... on linux these same applications use only "one" Qt library.

I listed a few disadvantages of this approach above. In addition, the version of Qt in Linux distros are usually a few versions behind so applications in the distro repository cannot make use the latest features, bugfixes, or improvements.

That's part of the reason why systems like AppImage and Snapcraft were invented. Sometimes, Linux users also want an app to contain a copy of its libraries, instead of having a single global copy of the libraries.

Upvotes: 4

Related Questions