Making use of Qt dependencies to avoid duplicaton of binaries

Viewed 71

Qt makes use of a lot of 3rd party libraries for image encoding, compression, encryption, audio and video codec support and whatnot.

Historically, I've always had to include those as additional dependencies when I want to utilize them. And I've always wondered if there is a way to simply reuse the binaries Qt already incorporates?

1 Answers

It really depends on the libraries, but generally speaking, it sadly is not possible.

Qt builds and links most 3rd party libraries statically and without exporting any symbols (See libpng as an example). Some are even only linked into the plugins and not the Qt libraries (like sqlite, which is only a pri-file that is imported by the plugin). The only way to find out for the concrete case is to check the src/3rdparty subfolders in the different Qt repositories.

There is also one other point to consider: Qt often tries to fulfill dependencies by using what the operating system provides. I.e. if Qt finds libpng on the host system, it typlically links against that library, so the code isn't even part of the Qt binaries anymore, making compiletime linking dependend on the Qt configuration, even if symbols are exported for a concrete library.

The only real exception to all this is if you link Qt statically. In that case, the linker will only pull in all those 3rdparty dependencies once you link the final application, making it possible for you to link against the libraries Qt uses.

Related