Important: Please read the Qt Code of Conduct -

Installing MQTT library

  • Re: Compile MQTT library & need to update to latest 5.11


    I have installed Qt on Debian 10 using the command

    sudo apt-get install qt5-default qtcreator qtdeclarative5-dev qtquick5* qml-module*

    I do not have much experience in linux, "just" want to build a touch UI for my Raspi (developing it on a different machine).

    I have the same error as mentioned in the above linked discussion:

    qmqttclient_p.h:49:10: fatal error: private/qobject_p.h: no such file or directory.

    Resolution seemed to be to call qmake from a different directory. So I wanted to call qmake from my path to Qt. Problem is, Qt is not installed in its default folder (/opt is empty). When I start the creator and look for its path using the PID it says


    there is also a qmakefile within the folder. Sadly, just calling
    results in the same old error.
    Terminal shows

    cd src/ && ( test -e Makefile || ***/usr/lib/qt5/bin/qmake*** -o Makefile /home/inso/qt/qtmqtt/src/ ) && make -f Makefile 
    make[1]: Verzeichnis „/home/inso/qt/qtmqtt/src“ wird betreten
    cd mqtt/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/inso/qt/qtmqtt/src/mqtt/ ) && make -f Makefile 
    make[2]: Verzeichnis „/home/inso/qt/qtmqtt/src/mqtt“ wird betreten
    g++ -c -include .pch/Qt5Mqtt -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -D_REENTRANT -fPIC -DQT_NO_FOREACH -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_MQTT_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I../../include -I../../include/QtMqtt -I../../include/QtMqtt/5.15.0 -I../../include/QtMqtt/5.15.0/QtMqtt -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.11.3 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.11.3/QtCore -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I.moc -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o .obj/qmqttclient.o qmqttclient.cpp
    In file included from qmqttclient.cpp:31:
    qmqttclient_p.h:49:10: fatal error: private/qobject_p.h: Datei oder Verzeichnis nicht gefunden
     #include <private/qobject_p.h>
    compilation terminated.
    make[2]: *** [Makefile:621: .obj/qmqttclient.o] Fehler 1
    make[2]: Verzeichnis „/home/inso/qt/qtmqtt/src/mqtt“ wird verlassen
    make[1]: *** [Makefile:45: sub-mqtt-make_first] Fehler 2
    make[1]: Verzeichnis „/home/inso/qt/qtmqtt/src“ wird verlassen
    make: *** [Makefile:47: sub-src-make_first] Fehler 2

    as the qmake of the right folder seems to be used, I am unsure what is going wrong now. I have also tried different other qmake-files, with no luck.

  • Lifetime Qt Champion

    Can you try with
    QT += core-private
    in the .pro file ?
    Make sure to do a make clean first and then retry

  • Just to be sure I did it right:

    the installation attemp was made using the Ubuntu terminal.

    I now have my open project within the qtcreator. There is a .pro-file (named as my project), where I already added "QT += mqtt".
    When I now clean the project, I get the error

    Project ERROR: Unknown module(s) in QT: mqtt

    so I comment it out, add "QT += core-private", save and clean the project, no errors.

    Then I again open the Ubuntu terminal, and enter

    This results in the same error as above.

  • Lifetime Qt Champion

    so it can still not find qobject_p.h ?
    have you check that you have this file ?

    sudo updatedb
    locate qobject_p.h

    (not sure Debian has locate but try )

    also where did you download qtmqtt source from ?

  • by executing apt-get install locate I was able to run commands updatedb and locate, both did not result in an output. So I´d assume it is not found?

    qtmqtt source was downloaded from

  • Lifetime Qt Champion

    yes if locate returns nothing then its not found.

    the url says Not found but i assume you use git clone ?
    Asking as im going to try it in my linux Mint. Not debian but as least related :)

  • Right, I found the tutorials

    from stackoverflow


    where I took partial instructions from.

    My Debian 10 x64 is running on VMWare Workstation Player 15.

  • Lifetime Qt Champion

    Odd. I get same error and i do have the file :)

    But then i open the .pro file in creator and then it just build.

    So I guess it a path issue from the shell.

  • @mrjj said in Installing MQTT library:


    I cannot find the folder gcc_64 on my machine, which should contain qobject_p.h

    I downloaded the whole OS to windows to search there again, it is definitely not there.
    Then I tried to reinstall gcc, no packages were loaded.
    find / -name gcc


    and, I can find the compiler as 32bit among the compilers in Qt.
    Semms to be installed fine, but only in 32 bit:

    inso@debian:~$ whereis gcc make
    gcc: /usr/bin/gcc /usr/lib/gcc
    make: /usr/bin/make /usr/share/man/man1/make.1.gz
    inso@debian:~$ gcc -v
    Using built-in specs.
    Target: x86_64-linux-gnu
    Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
    Thread model: posix
    gcc version 8.3.0 (Debian 8.3.0-6) 

    As it seems not to be installable later including the needed files, I now plan to build the virtual machine from scratch tomorrow, and instead of the terminal command used for installing Qt before, I now install by the online installer. Hopefully, this brings me the gcc-folder with the appropriate files, and also the folder management will be as it is by default.

    A second thing, assuming the same problem will occur (which seems obvious, as you had it too):
    Atm I am unsure how it works just opening the .pro file ( I´s assume). As I understand, atm on my machine the lib is not even installed as componnents are missing, no way.
    In your case, you verified the file is vailable. But you weren´t able to install the library, did I understand that right? And then you just open the file after opening your project, just by drag n drop to the editor, so the editor has loaded it besides the project and uses the path you chose while cloning to access the files? And then, everytime you work with this project, you have to open the .pro file separately?

  • Lifetime Qt Champion

    @Inso said in Installing MQTT library:

    But you weren´t able to install the library, did I understand that right?

    Not using the terminal and qmake but i then open the pro file in Creator and
    it build it. (yes simply go to File open project and browse to the in where ever you did git clone to )

    Then I added a build step to do "make install"
    and ran again and it installed it and i was able to use it in a project.

    qobject_p.h is not part of gcc install but should be part of the Qt install.
    the gcc_64 path comes from the Qt. Not related to the gcc compiler as such.

    But yes one diff can be you use the distro provided Qt and i installed via Qt installer.

    • And then, everytime you work with this project, you have to open the .pro file separately?

    No. It installed as a module and i can use it with
    QT += mqtt
    in a clean project.

  • Just a little update:
    bilding on this machine using the pro file in qt leads to:

    Project ERROR: Failed to run: perl -w /usr/lib/qt5/bin/ -module QtMqtt -version 5.15.0 -outdir '' -builddir '' /home/inso/qtmqtt

    Building on a machine using an online installer Qt works. Sadly Qt chashes on this machine, with no solution (see other thread). As I cannot install the Qt 12.x used by the machine where Qt is running fine, the running lib and running Qt are not compatible.
    I now try to install Qt on my native Windows machine. First try building mqtt endet in problems of the linker, I will waste the third evening trying to get the IDE running.

    If this will not result in an success, I deinstall Qt and switch to Java or .net. I know normally they sell Qt, seems they are not very interested in spreading the free version.

    However @mrii, you also took a lot of time taking a look at my problems. Thank you very much for that!

  • Lifetime Qt Champion

    I hope it works this time.
    Normally there is not many issues with installing Qt
    but seems you are particularly unlucky.

    Is this all on debian virtual machines ?

  • The above mentioned errors are both on debian machines. One builds the Lib, one builds the project.

    I now installed on Win10 home x64, opening using QtCreator, and building does not find the other header files, as he does not seem to like the "QtMqtt/". Deleting it, some calls are ambiguous, so no way building it this way here.

    I then installed GNUWin32 and tried to build it whis way. Started cmd as administrator, however, he says

    cd src\ && ( if not exist Makefile D:\Qt\5.15.0\mingw81_64\bin\qmake.exe -o Makefile D:\QtLibs\qtmqtt\src\ ) && D:/GnuWin32/bin/make -f Makefile
    make[1]: Entering directory `D:/QtLibs/qtmqtt/src'
    cd mqtt\ && ( if not exist Makefile D:\Qt\5.15.0\mingw81_64\bin\qmake.exe -o Makefile D:\QtLibs\qtmqtt\src\mqtt\ ) && D:/GnuWin32/bin/make -f Makefile
    make[2]: Entering directory `D:/QtLibs/qtmqtt/src/mqtt'
    D:/GnuWin32/bin/make -f Makefile.Release
    make[3]: Entering directory `D:/QtLibs/qtmqtt/src/mqtt'
    g++ -c -fno-keep-inline-dllexport -O2 -g -std=c++1z -fno-exceptions -Wall -Wextra -Wextra -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -DQT_NO_LINKED_LIST -DQT_NO_FOREACH -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_MQTT_LIB -DQT_BUILDING_QT -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I..\..\include -I..\..\include\QtMqtt -ID:/QtLibs/qtmqtt/include/QtMqtt/5.15.0 -ID:/QtLibs/qtmqtt/include/QtMqtt/5.15.0/QtMqtt -Itmp -ID:\Qt\5.15.0\mingw81_64\include -ID:\Qt\5.15.0\mingw81_64\include\QtNetwork -ID:\Qt\5.15.0\mingw81_64\include\QtCore\5.15.0 -ID:\Qt\5.15.0\mingw81_64\include\QtCore\5.15.0\QtCore -ID:\Qt\5.15.0\mingw81_64\include\QtCore -I.moc\release -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.7.25-winx64\include -IC:\Utils\postgresql\pgsql\include -ID:\Qt\5.15.0\mingw81_64\mkspecs\win32-g++  -o .obj\release\qmqttauthenticationproperties.o qmqttauthenticationproperties.cpp
    process_begin: CreateProcess(NULL, g++ -c -fno-keep-inline-dllexport -O2 -g -std=c++1z -fno-exceptions -Wall -Wextra -Wextra -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -DQT_NO_LINKED_LIST -DQT_NO_FOREACH -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_MQTT_LIB -DQT_BUILDING_QT -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I..\..\include -I..\..\include\QtMqtt -ID:/QtLibs/qtmqtt/include/QtMqtt/5.15.0 -ID:/QtLibs/qtmqtt/include/QtMqtt/5.15.0/QtMqtt -Itmp -ID:\Qt\5.15.0\mingw81_64\include -ID:\Qt\5.15.0\mingw81_64\include\QtNetwork -ID:\Qt\5.15.0\mingw81_64\include\QtCore\5.15.0 -ID:\Qt\5.15.0\mingw81_64\include\QtCore\5.15.0\QtCore -ID:\Qt\5.15.0\mingw81_64\include\QtCore -I.moc\release -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.7.25-winx64\include -IC:\Utils\postgresql\pgsql\include -ID:\Qt\5.15.0\mingw81_64\mkspecs\win32-g++ -o .obj\release\qmqttauthenticationproperties.o qmqttauthenticationproperties.cpp, ...) failed.
    make (e=2): Das System kann die angegebene Datei nicht finden.
    make[3]: *** [.obj/release/qmqttauthenticationproperties.o] Fehler 2
    make[3]: Leaving directory `D:/QtLibs/qtmqtt/src/mqtt'
    make[2]: *** [release] Fehler 2
    make[2]: Leaving directory `D:/QtLibs/qtmqtt/src/mqtt'
    make[1]: *** [sub-mqtt-make_first] Fehler 2
    make[1]: Leaving directory `D:/QtLibs/qtmqtt/src'
    make: *** [sub-src-make_first] Fehler 2

    and again, an unsuccessful build.

    I have some experience in VB6,, C++, C#, .net, Java, JavaScript and Python. I got PlatformIO to work flawlessly with my ESP32, Arduino and STM32. And I never, NEVER had problems with an IDE even close to this. Wow.

    Maybe someone could just upload his Qt5Mqtt.dll build on last stable (Qt 5.14.2) using Windows, so I can just copy it over? No matter I cannot debug on my Raspi, I´d just like to finish the project someway. Four free days and three are gone, would be awesome if I finally could get some to work before the long weekend is completely lost.

  • Lifetime Qt Champion

    Just tried on win 10. Qt 5.14.2
    I took other version than default from GIT

    git clone --branch 5.14.2

    Then i open pro file and it just build. (visual studio 2017)
    alt text

    Do note i have perl installed as thats an requiment for building Qt and also modules
    might also work

    I dont think the DLLs alone will do you much good as you cant do
    make install with them and i think the includes will be mising.
    but you are welcome to have them but do note its visual studio 2017 so
    cannto be used with mingw.

  • @mrjj
    I took a few days off, now it worked.
    The magic was not to use the last GIT version, as you did.
    I have chosen now the one closest to my QT-Version, which resulted in success both on raspbian and windows.
    Thanks again for your help !

Log in to reply