A Practical Guide for Self-Taught Programmers

Table of Contents
Getting Qt Creator To Work On Linux
If you have installed Qt Creator on Linux using the official online installer from qt.io and then tried to compile one of the built-in example programs, there is a good chance something went wrong. Maybe the build failed with a cryptic error message. Maybe the build succeeded but you could not find the executable anywhere. Either way, you are not alone, and it is not your fault.
This guide covers the two most common problems that trip up new Qt developers on Linux, and explains exactly how to fix both of them before they cost you hours of frustration.
Problem One: Missing System Dependencies
The Qt online installer does an excellent job of installing Qt’s own libraries and tools. What it does not do is install the underlying system libraries that Qt depends on. It simply assumes they are already there.
On a fresh Ubuntu or Debian system, many of those libraries are missing. The result is build failures with error messages like:
| cannot find -lGL QPA plugin could not be loaded xcb: could not connect to display |
None of these messages obviously say “you need to install a system package,” which makes them very hard to diagnose if you are just starting out.
The fix is straightforward, but the timing matters. Run the following command before you download or launch the Qt online installer. That way, everything Qt needs is already in place when Qt sets itself up on top of it.
| Important: Run this apt install command before launching the Qt online installer. |
| sudo apt install \ build-essential g++ make \ qt6-base-dev qt6-base-dev-tools qt6-tools-dev qt6-tools-dev-tools \ libqt6core6 libqt6gui6 libqt6widgets6 \ qt6-declarative-dev libqt6qml6 libqt6quick6 libqt6quickwidgets6 \ qml6-module-qtquick qml6-module-qtquick-controls \ qml6-module-qtquick-layouts qml6-module-qtquick-window \ qt6-multimedia-dev libqt6multimedia6 libqt6multimediawidgets6 \ gstreamer1.0-tools gstreamer1.0-plugins-base \ gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-libav \ libqt6network6 qt6-webengine-dev libqt6webenginecore6 \ libqt6webenginewidgets6 libqt6websockets6-dev \ libgl1-mesa-dev libglu1-mesa-dev libglew-dev libglfw3-dev \ qt6-shader-baker libqt6opengl6-dev \ libqt6svg6-dev libqt6printsupport6 libqt6xml6 \ libqt6sql6 libqt6sql6-sqlite libqt6sql6-mysql libqt6sql6-psql \ qt6-connectivity-dev libqt6bluetooth6 libqt6serialport6-dev \ qt6-positioning-dev qt6-sensors-dev \ libqt6concurrent6 libqt6dbus6 libqt6charts6-dev |
| Note: qt6-webengine-dev is the heaviest package on this list. It is essentially a full Chromium browser build and may require 1 to 2 gigabytes of disk space. If storage is limited, you can skip it and only add it later if a specific example requires it. |
Also note that package names can vary slightly between Ubuntu versions. If a package is not found, try running apt search qt6- to find the correct name for your system.
A Note on Build Systems: Use qmake, Not CMake
Starting with Qt 6, CMake became the officially recommended build system. However, qmake — Qt’s own original build system — works just as well for learning and running examples, and it is considerably simpler.
When creating a new project in Qt Creator, you will be asked to choose a build system. Select qmake. Most of the built-in example programs already include a .pro file, which is the qmake project file, so Qt Creator will use qmake automatically when you open them.
You do not need to install cmake. The only build-related packages you need from the apt command above are build-essential, g++, and make.
Problem Two: Shadow Build Directories
The second major frustration for new Qt developers is the shadow build. Qt Creator enables this by default, and it causes your compiled program to appear in a folder that has nothing obvious to do with your project.
By default, Qt Creator places all compiled output — object files, the Makefile, and your final executable — in a separate folder outside your project directory. The folder name looks something like this:
| /home/yourname/build-myproject-Desktop_Qt_6_x_x-Debug |
This folder is the shadow build directory. The idea behind it is sound: keeping compiled files separate from source files is considered good practice in professional development. But for someone just learning Qt, it means hitting Build, seeing the message Build Successful, and then having no idea where the program went.
The Recommended Fix: Build Inside a Subfolder
The cleanest solution is to tell Qt Creator to place build output inside a subfolder called build within your project directory. Here is what the resulting folder structure looks like:
| myproject/ ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── myproject.pro └── build/ ├── Makefile ├── myproject <- your executable is here └── (object files and other build output) |
Your source files stay clean and separate, and you always know exactly where to find your compiled program.
Here is a comparison of all three options so you can choose what works best for you:
| Option | Build Directory Setting | Result |
| Shadow build (Qt default) | Auto-generated path far from project | Executable ends up in a folder outside your project — hard to find |
| Build in source root | %{sourceDir} | Executable in same folder as your .cpp files — gets messy |
| Build in subfolder (recommended) | %{sourceDir}/build | Executable in a clean build/ folder inside your project — easy to find |
How to Change the Build Directory for One Project
- Open Qt Creator with your project loaded.
- Click on Projects in the left sidebar (the wrench icon).
- Under your kit — for example, Desktop Qt 6.x.x GCC 64bit — click Build.
- Find the Build directory field near the top of the panel.
- Clear the existing path and type:
| %{sourceDir}/build |
- Click the Build button (the hammer icon) to rebuild using the new location.
How to Make This the Global Default for All Projects
Rather than changing the setting project by project, you can set it once and have it apply to every new project you create going forward.
- Go to Edit, then Preferences. On older versions of Qt Creator this may be under Tools, then Options.
- Click Build and Run in the left panel.
- Click the Default Build Properties tab.
- In the Default build directory field, clear whatever is there and type:
| %{sourceDir}/build |
- Click OK.
| Important: This global setting only affects new projects created after you make the change. For projects you already have open, update the build directory manually in the Projects panel as described above. |
Recommended Setup Order
To summarize everything in this guide, here is the recommended order of steps for a clean Qt Creator installation on Ubuntu or Debian Linux:
- Run the apt install command listed above to install all system-level dependencies.
- Download the Qt online installer from qt.io and run it.
- During installation, select your preferred Qt version. When asked about the build system, choose qmake.
- Before creating your first project, open Edit, then Preferences, then Build and Run, then Default Build Properties, and set the default build directory to %{sourceDir}/build.
- Click OK, then start exploring the examples.
Following these steps in order means you will never encounter the missing dependency errors or the missing executable problem that catches so many beginners off guard.
Final Thoughts
Qt is a powerful and well-designed framework, and Qt Creator is an excellent development environment. The problems described in this guide are not flaws in Qt itself — they are gaps between what the installer handles and what a Linux system requires. Once these two issues are resolved, Qt Creator works smoothly and the learning experience is genuinely enjoyable.
Hopefully this guide saves you the hours of confusion that many self-taught programmers experience in their first days with Qt on Linux.
Please check out our Services!