1

My Qt application is failing to start with the following error: module "QtQuick.Controls" version 2.12 is not installed

My platform is Ubuntu 20.04.2 LTS. This is a well-known error on StackOverflow. Unfortunately, no answers have worked for me this far. I have exhausted all suggested remedies without any improvement. These are enumerated below:

  1. Checking compatibility of Qt with QuickControls: I am using Qt 5.12.8 in QtCreator, and QtCreator 4.11.0. I installed Qt using sudo apt install qt5 default and sudo apt-get install qtcreator. According to the documentation (see here, Qt 5.12 is directly compatible with QtQuick 2.12:
  2. Checking if I specified QtQuick as a dependency: In my .pro file, I have added QT += quick qml quickcontrols2
  3. Checking if I have the right libraries: I have qtquickcontrols2-5-dev, qt5declarative5-dev, and qml-module-qtquick-controls. Furthermore, apt-cache search qtquick shows me that all the qtquick modules are there
  4. Re-installing qtcreator: Some questions suggest re-installing QtCreator. I have tried this, but it had no effect
  5. QML Emulation layer: I have configured my project to "Use QML emulation layer that is built with the selected Qt". However, this also had no effect

Having performed every one of these steps, and exhausted all StackOverflow questions and Github threads related to the topic, I still cannot find what is causing this issue.


I have additionally included some related questions that I've tried. Question 4 is perhaps the closest to mine, but was solved via the Yocto build system that I am not using:

  1. import QtQuick.Controls 2.1 QML MODULE NOT FOUND
  2. Error module "QtQuick" version 2.12 is not installed
  3. Ubuntu QT install qt quick controls 2.1
  4. Qt - Module "QtQuick.Controls" is not installed

I would be extremely appreciative of any advice on further resolving this matter.

Micrified
  • 3,338
  • 4
  • 33
  • 59
  • How are you running the application? From within QtCreator or external (i.e. from command line). – Amfasis Apr 08 '21 at 13:17
  • @Amfasis From within QtCreator. Although I've also just executed the binary myself from the terminal. Neither work – Micrified Apr 08 '21 at 13:18
  • do you find `libQt5QuickControls2.so.5` in the output of `ldconfig` (or `sudo ldconfig`)? – Amfasis Apr 08 '21 at 13:22
  • @Amfasis In `/usr/lib/x86_64-linux-gnu`, I have `libQt5QuickControls2.so.5`, `libQt5QuickControls2.so.5.12`, and `libQt5QuickControls2.so.5.12.8`. – Micrified Apr 08 '21 at 13:28
  • but if those are not found by `ldconfig` you need to update your ld-conf. You can probably run the application with `LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu app`? – Amfasis Apr 08 '21 at 13:34
  • @Amfasis You know, maybe it is a problem with ldconfig. Running `sudo ldconfig` returns nothing. Only when I add the `-v` flag did I find where those libraries were and listed their locations here. What should I be seeing from just running `sudo ldconfig` with no flags? – Micrified Apr 08 '21 at 13:39
  • oh shoot, I meant `sudo ldconfig -p` to print the cache – Amfasis Apr 08 '21 at 14:07
  • Running `sudo ldconfig -p | grep ''Quick''` gets me `libQt5QuickControls2.so.5 (libc6,x86-64) => /lib/x86_64-linux-gnu/libQt5QuickControls2.so.5` and `libQt5QuickControls2.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libQt5QuickControls2.so` – Micrified Apr 08 '21 at 14:12
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/230894/discussion-between-amfasis-and-micrified). – Amfasis Apr 08 '21 at 14:20

1 Answers1

1

You are missing the qml module for controls 2 because you have installed qml-module-qtquick-controls instead of qml-module-qtquick-controls2.

The QML engine will look for a module inside the path from QML2_IMPORT_PATH, by following the namespaces, so in this case QML2_IMPORT_PATH/QtQuick/Controls and QML2_IMPORT_PATH/QtQuick/Controls.2 (see version semantics documentation ). If in these folders it finds a qmldir file, it will parse it and look for any component that has at least 2 as major and something lower or equal to 12 as minor (allthough this particular qmldir doesn't state any components... it probably also reads the libqtquickcontrols2plugin.so or plugin.qmltypes)

Amfasis
  • 3,932
  • 2
  • 18
  • 27