Skip to content

Linux QT Development Environment Setup

Warning

Before you dive into Qt development, please make sure you have the knowledge of different licenses Qt provided, LGPL-3.0, GPL and commercial license. Make sure choose the right tools and edition for your project to avoid legal suites. We do not assume responsibility towards or accept liability to any other person for the contents of this tutorial.

Qt is a cross-platform C++ application development framework widely used for desktop, embedded, and mobile devices. Setting up the Qt development environment on a Linux system is a relatively straightforward process, involving a series of steps to ensure all dependencies are correctly installed.

Preparation

Tip

Installation operations need to be performed in an online environment.

  • Operating System: Linux distribution (Ubuntu).
  • Package Manager: apt, yum.

Dependency Installation

Ensure the relevant environment and dependencies are installed before installing Qt.

1. Install the basic compilation toolchain.

sudo apt update
sudo apt install build-essential

Verify GCC/G++: No need to install separately; build-essential includes them:

gcc --version
g++ --version
make -v

2. Install the clang compiler.

sudo apt install clang
clang -v
sudo apt install clang++
clang++ -v

3. Install make-guile.

sudo apt install make-guile

4. Install cmake.

sudo snap install cmake

Install Qt

1. Update the package list.

sudo apt update
sudo apt upgrade

2. Install the Qt 5 core development libraries using the following command.

sudo apt install -y qtbase5-dev qt5-qmake qtbase5-dev-tools

3. Install all packages starting with qt5.

sudo apt-get install qt5*

4. Install missing Qt QML/Quick development libraries.

Tip

The commands here need to be chosen based on the system architecture.

//Linux Desktop System (x86_64)
sudo apt install -y qtdeclarative5-dev
sudo apt install -y qtquickcontrols2-5-dev
//aarch64 Embedded Development Board
sudo apt install -y qtdeclarative5-dev:arm64

5. Verify the installation. Open a terminal and run the following command to confirm Qt is installed correctly.

qmake --version
//Qt Version
QMake version 3.1
Using Qt version 5.15.3 in /usr/lib/x86_64-linux-gnu

6. (Optional) Install common Qt5 modules. If specific functionalities (like network, database, GUI components, etc.) are needed during development, install the corresponding modules additionally.

//Example: SQL, GUI extension modules
sudo apt install -y libqt5sql5-dev libqt5widgets5-dev

Install QT Creator

Qt Creator is the development IDE for Qt, providing an intuitive user interface for creating and managing Qt projects.

1. Install Qt Creator.

sudo apt install qtcreator

2. Open a terminal and enter the following command to start Qt Creator.

qtcreator

Configure Development Environment

1. Create a New Project: Open Qt Creator, click "File" > "New File or Project" > "Qt Widgets Application". Follow the prompts to enter the project name and save path.

2. Configure Project: In the "Projects" menu, you can configure the compiler, build directory, debugger, etc.

image-20251105153503971

3. Run Program: In the "examples" menu, select an example project to run.

Warning

When running different example projects, they might fail due to missing relevant libraries or classes. Adjustments need to be made based on the error messages.