Add MQTT module to QT project
-
I am trying to add MQTT functionality in a QT project (based on QGroundControl).
Just as in this case: How can i add module mqtt to QT? , I am trying to use the QMQTT library. The solution proposed at the aforementioned thread do not seem to work for me (I am using windows).
I did the following:- added the qmqtt lib folder to E:\QGC\Stable_V4.0\libs
- added the command "add_subdirectory(qmqtt)" to the project's CMakeLists.txt
- added "#include "qmqtt.h"" to main.c
- added the line "QT += mqtt"
I constantly get the error "Project ERROR: Unknown module(s) in QT: mqtt"
Any help would be appreciated.
-
@gampo said in Add MQTT module to QT project:
E:\QGC\Stable_V4.0\libs
Is that your Qt installation or why do you add qmqtt there?
-
Thank you very much for responding, let alone so quickly.
I assumed the project's libs folder should contain all the used libraries, so I added the downloaded lib folder to the project's one.
Apologies if this is a newbie mistake...P.S. took many minute for me to respond due to my being new to the forum and thus having a mandatory 10-minute delay between posts.
-
Are you aware of the installation path to which MQTT should be added?
I assume it must be E:\Qt\5.15.0\Src\qttools\src, right?
Also , should I add the entire library folder (containing the CMakeLists files etc) or just the folder containing the .h, .cpp, .pro and .pri files?As for points 2 and 4, you are right, I mixed things up... I will delete the CMakeList command and only use QMake from at the projects .pro file.
-
@gampo You should first explain what exactly you're trying to install. What did you actually download exactly?
Usually you would download source code and do:mkdir build_qmqtt cd build_qmqtt PATH_TO_YOUR_QMAKE ../qmqtt_src make make install
"make install" would install everything needed in your Qt installation.
-
@jsulm
I downloaded the entire qmqtt repository containing:- an "examples" subfolder
- a "src" subfolder containing an "mqtt" sub-subfolder
- a "test" subfolder
All the .h and .cpp files are inside the mqtt sub-subfolder.
I am on windows so I can sadly not follow the linux installation process... -
@gampo Then you first need to build it. What I posted is not really Linux instructions. You have to do the same on Windows also. Use the command prompt from MinGW or MSVC (what ever you're using). make will be either nmake.exe (MSVC) or mingw32-make.exe (MinGW).
-
I opened a MSVC terminal and directed to E:\QtMQTT\qmqtt\build_qmqtt, but can't proceed after that point...
Typing "NMAKE: E:\QtMQTT\qmqtt\src gives "'NMAKE:' is not recognized as an internal or external command, operable program or batch file".
I am really sorry, I lack the experience with such environments.Edit: I made a pastebin with the folder tree if it helps at all:
https://pastebin.com/ZXShYcmT -
@gampo said in Add MQTT module to QT project:
Typing "NMAKE: E:\QtMQTT\qmqtt\src gi
First, call qmake.
There must not be : after nmake:PATH_TO_QMAKE nmake nmake install