How can I install Qt 5.x on 12.04 LTS?

This can be done by adding the following PPA to your system:

ppa:canonical-qt5-edgers/ubuntu1204-qt5 Launchpad logo (Click here for instructions on using PPAs.)

You can usually do this with the following commands:

sudo apt-add-repository ppa:canonical-qt5-edgers/ubuntu1204-qt5
sudo apt-get update

The next step is to install the necessary packages for Qt5 / QML 2.0 development. You can do that by running these command:

sudo apt-get install qtdeclarative5-dev

This will install the headers / libraries necessary for development with desktop Qt and QML. You will also probably want to grab the latest release of Qt Creator from this page.

I've found that Qt Creator sometimes has problems finding your new Qt5 installation. If that is the case, perform these steps:

  1. open it up and go to Tools->Options
  2. click the "Build & Run" section in the left menu
  3. click the "Qt Versions" tab
  4. click "Add..." and enter the location that corresponds with your OS:

    32-bit: /usr/lib/i686-linux-gnu/qt5/bin/qmake
    64-bit: /usr/lib/x86_64-linux-gnu/qt5/bin/qmake

Previously these packages were located here:

ppa:ubuntu-sdk-team/ppa Launchpad logo

According to the "Ubuntu SDK Team": Old Ubuntu 12.04 LTS Qt 5.0 packages have been moved to https://launchpad.net/~canonical-qt5-edgers/+archive/ubuntu/ubuntu1204-qt5/, and that seems to have occurred sometime in May of 2016.


Ubuntu SDK team PPA (ppa:ubuntu-sdk-team/ppa) provides only Qt 5.0 for Ubuntu 12.04.

If you need features from newer Qt versions you can use the new PPAs by Stephan Binner for Precise and Trusty. He created PPAs for all Qt version starting from 4.8.

In order to not mess with Qt system packages, the packages from this PPA are installed in /opt so you'll have to inform the correct path (/opt/qtXX/include) to your build tool (if you don't use the Qt Creator provided by the PPA).


Instructions

  1. Choose a PPA

    From Stephan's profile page on Launchpad, choose the PPA that matches the Qt version you want and the Ubuntu version you have. Remember that Precise is Ubuntu 12.04 and Trusty is Ubuntu 14.04.

    Supposing you want to install Qt 5.5 on Ubuntu 12.04 you should choose Qt 5.5.1 for /opt Precise (the latest Qt version available for Precise at the time of this writing).

    To install Qt 5.5 on Ubuntu 14.04 choose Qt 5.5.1 for /opt Trusty.

  2. Add the PPA to your system

    Open the PPA page. You should see something like this:

    enter image description here

    Then run apt-add-repository followed by the bold text from above (use the actual PPA address from the PPA page!):

    sudo apt-add-repository ppa:beineri/opt-qt551
    
  3. Update package lists an install Qt

    Run the following to download the package list from the added repository and install Qt (and Qt Creator):

    sudo apt-get update
    sudo apt-get install qt-latest qtcreator-latest