How to install Qt on Ubuntu

Install Qt on Ubuntu instructionsIntroduction

This tutorial gives instrustions how to install Qt 5.9.0 on Ubuntu 16.04. Perhaps it can be used for newer versions of Qt and Ubuntu too. A difference for OpenGL has been found and added as a note below.

Seven steps to install Qt on Ubuntu

Step 1. Download Qt
Visit Qt downloads page to choose a 32-bit or 64-bit Linux installation depending your version of Ubuntu. The installation file can be also downloaded through the command line using wget.


Step 2. Install Qt on Ubuntu
Adjust permission, run the installer and follow the instruction to complete the installation.

Step 3. Install g++
Open a terminal and execute the following command to install g++ :

Step 4. Install generic font configuration library – runtime
Open a terminal and execute the following command to install the full runtime files for the generic font configuration library:

Step 5. Configure a compiler
Launch Qt Creator. Go to Tools > Options. Click Build & Run and select tab Kit. Configure a compiler if it is not automatically detected.

Step 6. Install OpenGL libraries
Execute the following command to install OpenGL libraries:

Note: Just installing the above-mentioned mesa-common-dev kit is not sufficient for more recent Ubuntu versions. Based on a comment in the Qt forum an additional package needs installation. Execute following command:

Step 7. Set file association with pro files
When installing from the on-line source the file association is not done automatically. It also not show up when you try to associate it with file explorer. Create a file named “Qt-Creator.desktop” and fill the file with the following.

Place this file in home .local/share/applications

Edit a file named “defaults.list” in the same directory . Add the following line.

open file mimeapps.list and check if the following line is present.

if not add it under [added Associations].

Run the following command.

now Qt has been added to the list of file associations.

Troubleshooting with Qt 5 installation

  • Qt Creator needs a compiler set up to build

Follow the instruction from the previous section to configure compiler for Qt Creator.

  • error: g++: Command not found


  • error: GL/gl.h: No such file or directory