How to install build dependencies of Qt on Ubuntu

Qt requires many dependencies to build and it's really hard to find a complete list of them. In this post, I'll show you how to install all dependencies for building Qt using APT package manager on Ubuntu.

Finding packages

Ubuntu manages Qt in the form of several shattered packages. First, you need to find package names which contains Qt module that you want to build.

You can list packages that contain a specific keyword in their package name using a command below.

$ apt-cache pkgnames <keyword>

Or, you can list packages that contain a specific keyword in their package name and description using command below.

$ apt-cache search <keyword>

Installing dependencies

You can install all dependencies of a specific package using a command below.

$ apt-get build-dep <package_name>

Using this command, you can do this:

$ apt-get build-dep $(apt-cache pkgnames qtbase qt5 qtdeclarative)

That's all. You can build Qt now. If you still don't meet dependencies for a module, find a package for that module and do the same.