Are you an Ubuntu Linux user and developer that needs Qt 5 installed on your system? Can’t figure out what packages to install to use it? We can help! Follow along with this guide as we go over how to install Qt 5 on Linux!
Install Qt 5 on Ubuntu via official software repositories – terminal
If you’re using Ubuntu, the best way to get Qt 5 up and running on your system is through the official Ubuntu software repositories. To start the installation process, you must open up a terminal window.
To open up a terminal window on the Ubuntu Linux desktop, press Ctrl + Alt + T on the keyboard. Alternatively, search for “Terminal” in the app menu and open it up that way.
Once the terminal window is open on the Ubuntu desktop, the installation can begin. Using the apt install command, set up the “qt5-default” package on your computer.
sudo apt install qt5-default
After typing in the apt install command above, Ubuntu will ask you for your password. The reason it is asking for your password is that sudo requires a password. Type in your user password and press the Enter key. Do not worry if you do not see any password feedback.
If your password was entered successfully, the terminal should accept it and attempt to collect all dependencies required for the “qt5-default” package on your system. Once all dependencies are collected, press the Y button to continue with the installation.
The installation of Qt 5 using the official Ubuntu software sources should be quick, as only a handful of things need to be downloaded and installed on your system. For more information on Qt 5, check out the official documentation.
Install Qt 5 on Ubuntu via official software repositories – GUI
If you’d prefer to set up Qt 5 on your Ubuntu PC using the GUI, the best way to go is with the Synaptic Package Manager. It’s an excellent application that gives Ubuntu users the ability to search and install packages without touching the terminal.
Sadly, Synaptic doesn’t come pre-installed on Ubuntu systems anymore. To get it working, open up Ubuntu Software, search for “Synaptic,” and install it. Once you’ve got it working, open it via the app menu.
With Synaptic Package Manager open, look for the “Search” button in the top-right section of the app, and click on it with the mouse. Then, click on the text box next to “Search” and type out “qt5-default”.
After typing out your search term, find the “search” button inside of the pop-up window and click it to perform a search of the Ubuntu software repositories. The search should not take long.
Look through the search results for “qt5-default,” and right-click on it with the mouse. Inside the right-click menu, look for the option “Mark for installation” and select it.
Now that the “qt5-default” package is marked for installation in Synaptic Package Manager locate the “Apply” button and select it with the mouse. When you click “Apply,” Synaptic will attempt to download and install Qt 5 on your Ubuntu PC.
The installation shouldn’t take too long. When the process is complete, close Synaptic Package Manager as it is no longer necessary. For more information on Qt 5 for Linux, check the documentation.
Install Qt 5 on Ubuntu via the Qt website
While it is highly recommended to install Qt 5 on Ubuntu using Ubuntu’s official packages, it is also possible to download Qt 5 from the website and install it that way.
To start the installation of Qt 5 via the official website, open up a terminal window. You can open up a terminal window on the Ubuntu desktop with Ctrl + Alt + T or search for “Terminal” in the app menu.
Once the terminal window is open, make use of the wget command to download the latest Qt 5 from the website.
wget https://download.qt.io/official_releases/qt/5.12/5.12.10/qt-opensource-linux-x64-5.12.10.run
After downloading Qt 5, you must update the permissions of the file so that it can be executed as a program.
sudo chmod +x qt-opensource-linux-x64-5.12.10.run
Execute the Qt 5 run file to start the installation.
./qt-opensource-linux-x64-5.12.10.run
Following the installation of the Qt 5 run file, you must install various dependencies. These dependencies are required for Qt 5 to run correctly on Ubuntu.
sudo apt install libfontconfig1 build-essential mesa-common-dev libglu1-mesa-dev
After installing all of these dependencies, you will need to create a desktop entry for Ubuntu. To do this, enter the commands below.
touch ~/.local/share/applications/Qt-Creator.desktop echo "[Desktop Entry] Version=1.0 Encoding=UTF-8 Type=Application Name=QtCreator Comment=QtCreator NoDsiplay=true Exec=(Install folder of QT)/Tools/QtCreator/bin/qtcreator %f Icon=(Install folder of QT)/5.4/Src/qtdoc/doc/images/landing/icon_QtCreator_78x78px.png Name[en_US]=Qt-Creator" > ~/.local/share/applicationsQt-Creator.desktop
Update the permissions of the Qt Creator file with chmod.
sudo chmod +x ~/.local/share/applicationsQt-Creator.desktop
Make Qt the default file association for pro files on Ubuntu using echo.
echo "text/qtcreator=Qt-Creator.desktop;" >> ~/.local/share/applications/defaults.list
After adding the file association, everything should work.