Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to find MQTT examples
Forum Updated to NodeBB v4.3 + New Features

How to find MQTT examples

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 3 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS SGaist

    You need to build and install the module before you can use it.

    You can do that from Qt Creator (requires an additional step for the install).

    L Offline
    L Offline
    lukutis222
    wrote on last edited by
    #5

    @SGaist
    Oh okay.
    Would you be able to provide more information on that? How can I do this?

    SGaistS 1 Reply Last reply
    0
    • L lukutis222

      @SGaist
      Oh okay.
      Would you be able to provide more information on that? How can I do this?

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #6

      There is not much more to it than what I wrote:

      Open the top level CMakeLists.txt of the module with Qt Creator and use the Qt version you want to develop with to build the module.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 1 Reply Last reply
      0
      • SGaistS SGaist

        There is not much more to it than what I wrote:

        Open the top level CMakeLists.txt of the module with Qt Creator and use the Qt version you want to develop with to build the module.

        L Offline
        L Offline
        lukutis222
        wrote on last edited by lukutis222
        #7

        @SGaist

        Thanks for the help but that does not seem to be as straightforward as you say.

        I tried to open and build the top level CMakeLists.txt but there are errors.
        0e14a676-9629-47a6-84fd-dbe4a991ab5a-image.png

        I am currently looking into how to solve this cmake issue.

        jsulmJ 1 Reply Last reply
        0
        • L lukutis222

          @SGaist

          Thanks for the help but that does not seem to be as straightforward as you say.

          I tried to open and build the top level CMakeLists.txt but there are errors.
          0e14a676-9629-47a6-84fd-dbe4a991ab5a-image.png

          I am currently looking into how to solve this cmake issue.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #8

          @lukutis222 You are apparently on the dev branch, checkout the branch corresponding to your Qt version.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          L 1 Reply Last reply
          1
          • jsulmJ jsulm

            @lukutis222 You are apparently on the dev branch, checkout the branch corresponding to your Qt version.

            L Offline
            L Offline
            lukutis222
            wrote on last edited by lukutis222
            #9

            @jsulm

            Well spotted sir!

            After I checked out to required branch with command:

            git checkout 6.5.0
            

            I have managed to build it:

            16:51:17: Running steps for project QtMqtt...
            16:51:17: Starting: "C:\Qt\Tools\CMake_64\bin\cmake.exe" --build C:/Users/Lukas/Desktop/Programming/QT/MQTT/build-qtmqtt-Desktop_Qt_6_5_0_MinGW_64_bit-Debug --target all
            ninja: no work to do.
            16:51:17: The process "C:\Qt\Tools\CMake_64\bin\cmake.exe" exited normally.
            16:51:17: Elapsed time: 00:00.
            

            I have now this build folder containing all the files:

            f7174b5f-651e-4890-8d26-1e3f60e011be-image.png

            I assume the next step after building the module is to install it. I am looking into how this can be done at the moment

            Additionally, I tried something else:

            TEST#1
            I found this stackoverflow thread:
            https://stackoverflow.com/questions/66367858/install-mqtt-module-in-open-source-qt

            It seems that there is some additional steps missing as this suggestion also does not seem to work:

            C:\Users\Lukas>cd C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt
            
            C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt>qmake
            Usage: qmake [mode] [options] [files]
            
            QMake has two modes, one mode for generating project files based on
            some heuristics, and the other for generating makefiles. Normally you
            shouldn't need to specify a mode, as makefile generation is the default
            mode for qmake, but you may use this to test qmake on an existing project
            
            Mode:
              -project       Put qmake into project file generation mode
                             In this mode qmake interprets [files] as files to
                             be added to the .pro file. By default, all files with
                             known source extensions are added.
                             Note: The created .pro file probably will
                             need to be edited. For example add the QT variable to
                             specify what modules are required.
              -makefile      Put qmake into makefile generation mode (default)
                             In this mode qmake interprets files as project files to
                             be processed, if skipped qmake will try to find a project
                             file in your current working directory
            
            Warnings Options:
              -Wnone         Turn off all warnings; specific ones may be re-enabled by
                             later -W options
              -Wall          Turn on all warnings
              -Wparser       Turn on parser warnings
              -Wlogic        Turn on logic warnings (on by default)
              -Wdeprecated   Turn on deprecation warnings (on by default)
            
            Options:
               * You can place any variable assignment in options and it will be *
               * processed as if it was in [files]. These assignments will be    *
               * processed before [files] by default.                            *
              -o file        Write output to file
              -d             Increase debug level
              -t templ       Overrides TEMPLATE as templ
              -tp prefix     Overrides TEMPLATE so that prefix is prefixed into the value
              -help          This help
              -v             Version information
              -early         All subsequent variable assignments will be
                             parsed right before default_pre.prf
              -before        All subsequent variable assignments will be
                             parsed right before [files] (the default)
              -after         All subsequent variable assignments will be
                             parsed after [files]
              -late          All subsequent variable assignments will be
                             parsed right after default_post.prf
              -norecursive   Don't do a recursive search
              -recursive     Do a recursive search
              -set <prop> <value> Set persistent property
              -unset <prop>  Unset persistent property
              -query <prop>  Query persistent property. Show all if <prop> is empty.
              -qtconf file   Use file instead of looking for qt6.conf, then qt.conf
              -cache file    Use file as cache           [makefile mode only]
              -spec spec     Use spec as QMAKESPEC       [makefile mode only]
              -nocache       Don't use a cache file      [makefile mode only]
              -nodepend      Don't generate dependencies [makefile mode only]
              -nomoc         Don't generate moc targets  [makefile mode only]
              -nopwd         Don't look for files in pwd [project mode only]
            
            C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt>make
            make: *** No targets specified and no makefile found.  Stop.
            
            C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt>make install
            make: *** No rule to make target `install'.  Stop.
            
            C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt>
            

            TEST#2

            I tried to follow this video:
            https://www.youtube.com/watch?v=DGB0GfFRqPo&ab_channel=EmbeddedLaboratory

            But also failed:

            C:\Users\Lukas>cd C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt\build
            
            C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt\build>C:\Qt\Tools\CMake_64\bin\cmake --build .
            Error: could not load cache
            
            C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt\build>C:\Qt\6.5.0\mingw_64\bin\qt-configure-module ..
            'C:\Qt\6.5.0\mingw_64\bin\\qt-cmake-private.bat' '..'
            CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
            CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
            CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
            -- Configuring incomplete, errors occurred!
            See also "C:/Users/Lukas/Desktop/Programming/QT/MQTT/qtmqtt/build/CMakeFiles/CMakeOutput.log".
            CMake Error at C:/Qt/6.5.0/mingw_64/lib/cmake/Qt6/QtProcessConfigureArgs.cmake:994 (message):
              CMake exited with code 1.
            
            
            
            C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt\build>C:\Qt\6.5.0\mingw_64\bin\qt-configure-module ..
            'C:\Qt\6.5.0\mingw_64\bin\\qt-cmake-private.bat' '..'
            CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
            CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
            CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
            -- Configuring incomplete, errors occurred!
            See also "C:/Users/Lukas/Desktop/Programming/QT/MQTT/qtmqtt/build/CMakeFiles/CMakeOutput.log".
            CMake Error at C:/Qt/6.5.0/mingw_64/lib/cmake/Qt6/QtProcessConfigureArgs.cmake:994 (message):
              CMake exited with code 1.
            
            SGaistS 1 Reply Last reply
            0
            • L lukutis222

              @jsulm

              Well spotted sir!

              After I checked out to required branch with command:

              git checkout 6.5.0
              

              I have managed to build it:

              16:51:17: Running steps for project QtMqtt...
              16:51:17: Starting: "C:\Qt\Tools\CMake_64\bin\cmake.exe" --build C:/Users/Lukas/Desktop/Programming/QT/MQTT/build-qtmqtt-Desktop_Qt_6_5_0_MinGW_64_bit-Debug --target all
              ninja: no work to do.
              16:51:17: The process "C:\Qt\Tools\CMake_64\bin\cmake.exe" exited normally.
              16:51:17: Elapsed time: 00:00.
              

              I have now this build folder containing all the files:

              f7174b5f-651e-4890-8d26-1e3f60e011be-image.png

              I assume the next step after building the module is to install it. I am looking into how this can be done at the moment

              Additionally, I tried something else:

              TEST#1
              I found this stackoverflow thread:
              https://stackoverflow.com/questions/66367858/install-mqtt-module-in-open-source-qt

              It seems that there is some additional steps missing as this suggestion also does not seem to work:

              C:\Users\Lukas>cd C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt
              
              C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt>qmake
              Usage: qmake [mode] [options] [files]
              
              QMake has two modes, one mode for generating project files based on
              some heuristics, and the other for generating makefiles. Normally you
              shouldn't need to specify a mode, as makefile generation is the default
              mode for qmake, but you may use this to test qmake on an existing project
              
              Mode:
                -project       Put qmake into project file generation mode
                               In this mode qmake interprets [files] as files to
                               be added to the .pro file. By default, all files with
                               known source extensions are added.
                               Note: The created .pro file probably will
                               need to be edited. For example add the QT variable to
                               specify what modules are required.
                -makefile      Put qmake into makefile generation mode (default)
                               In this mode qmake interprets files as project files to
                               be processed, if skipped qmake will try to find a project
                               file in your current working directory
              
              Warnings Options:
                -Wnone         Turn off all warnings; specific ones may be re-enabled by
                               later -W options
                -Wall          Turn on all warnings
                -Wparser       Turn on parser warnings
                -Wlogic        Turn on logic warnings (on by default)
                -Wdeprecated   Turn on deprecation warnings (on by default)
              
              Options:
                 * You can place any variable assignment in options and it will be *
                 * processed as if it was in [files]. These assignments will be    *
                 * processed before [files] by default.                            *
                -o file        Write output to file
                -d             Increase debug level
                -t templ       Overrides TEMPLATE as templ
                -tp prefix     Overrides TEMPLATE so that prefix is prefixed into the value
                -help          This help
                -v             Version information
                -early         All subsequent variable assignments will be
                               parsed right before default_pre.prf
                -before        All subsequent variable assignments will be
                               parsed right before [files] (the default)
                -after         All subsequent variable assignments will be
                               parsed after [files]
                -late          All subsequent variable assignments will be
                               parsed right after default_post.prf
                -norecursive   Don't do a recursive search
                -recursive     Do a recursive search
                -set <prop> <value> Set persistent property
                -unset <prop>  Unset persistent property
                -query <prop>  Query persistent property. Show all if <prop> is empty.
                -qtconf file   Use file instead of looking for qt6.conf, then qt.conf
                -cache file    Use file as cache           [makefile mode only]
                -spec spec     Use spec as QMAKESPEC       [makefile mode only]
                -nocache       Don't use a cache file      [makefile mode only]
                -nodepend      Don't generate dependencies [makefile mode only]
                -nomoc         Don't generate moc targets  [makefile mode only]
                -nopwd         Don't look for files in pwd [project mode only]
              
              C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt>make
              make: *** No targets specified and no makefile found.  Stop.
              
              C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt>make install
              make: *** No rule to make target `install'.  Stop.
              
              C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt>
              

              TEST#2

              I tried to follow this video:
              https://www.youtube.com/watch?v=DGB0GfFRqPo&ab_channel=EmbeddedLaboratory

              But also failed:

              C:\Users\Lukas>cd C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt\build
              
              C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt\build>C:\Qt\Tools\CMake_64\bin\cmake --build .
              Error: could not load cache
              
              C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt\build>C:\Qt\6.5.0\mingw_64\bin\qt-configure-module ..
              'C:\Qt\6.5.0\mingw_64\bin\\qt-cmake-private.bat' '..'
              CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
              CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
              CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
              -- Configuring incomplete, errors occurred!
              See also "C:/Users/Lukas/Desktop/Programming/QT/MQTT/qtmqtt/build/CMakeFiles/CMakeOutput.log".
              CMake Error at C:/Qt/6.5.0/mingw_64/lib/cmake/Qt6/QtProcessConfigureArgs.cmake:994 (message):
                CMake exited with code 1.
              
              
              
              C:\Users\Lukas\Desktop\Programming\QT\MQTT\qtmqtt\build>C:\Qt\6.5.0\mingw_64\bin\qt-configure-module ..
              'C:\Qt\6.5.0\mingw_64\bin\\qt-cmake-private.bat' '..'
              CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
              CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
              CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
              -- Configuring incomplete, errors occurred!
              See also "C:/Users/Lukas/Desktop/Programming/QT/MQTT/qtmqtt/build/CMakeFiles/CMakeOutput.log".
              CMake Error at C:/Qt/6.5.0/mingw_64/lib/cmake/Qt6/QtProcessConfigureArgs.cmake:994 (message):
                CMake exited with code 1.
              
              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #10

              If you want to install from the command line, go to the build folder.

              As for the cmake issue, use the ˋqt-cmake ` wrapper found in the bin folder of the 6.5.0 installation,

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              L 1 Reply Last reply
              0
              • SGaistS SGaist

                If you want to install from the command line, go to the build folder.

                As for the cmake issue, use the ˋqt-cmake ` wrapper found in the bin folder of the 6.5.0 installation,

                L Offline
                L Offline
                lukutis222
                wrote on last edited by lukutis222
                #11

                @SGaist
                Its a little bit more confusing as there is probably more than 1 method of doing this. It would be probably better to stick to a single method ( the one that we initially started maybe ) as I am a little bit overwhelmed by complexity of building and installing mqtt module.

                Please lets go a step backwards and continue from where we left initially.
                So now that I managed to build the top level project after i checked out to the correct branch and I have the following build folder:

                build-qtmqtt-Desktop_Qt_6_5_0_MinGW_64_bit-Debug
                

                Would you be able to provide further instructions as I didint manage to find any relevant information on youtube/stackoverflow or qt forums on what would be the next step.

                After I figure this all out, il be sure to provide detailed step by step instructions on how to build and install this mqtt module for dummies as it is way too complex as it currently is.

                SGaistS 1 Reply Last reply
                0
                • L lukutis222

                  @SGaist
                  Its a little bit more confusing as there is probably more than 1 method of doing this. It would be probably better to stick to a single method ( the one that we initially started maybe ) as I am a little bit overwhelmed by complexity of building and installing mqtt module.

                  Please lets go a step backwards and continue from where we left initially.
                  So now that I managed to build the top level project after i checked out to the correct branch and I have the following build folder:

                  build-qtmqtt-Desktop_Qt_6_5_0_MinGW_64_bit-Debug
                  

                  Would you be able to provide further instructions as I didint manage to find any relevant information on youtube/stackoverflow or qt forums on what would be the next step.

                  After I figure this all out, il be sure to provide detailed step by step instructions on how to build and install this mqtt module for dummies as it is way too complex as it currently is.

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by SGaist
                  #12

                  Check the bottom right part of this image of this stack overflow post

                  alt text

                  Just add that step and it should install the module.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  L 2 Replies Last reply
                  0
                  • SGaistS SGaist

                    Check the bottom right part of this image of this stack overflow post

                    alt text

                    Just add that step and it should install the module.

                    L Offline
                    L Offline
                    lukutis222
                    wrote on last edited by lukutis222
                    #13

                    @SGaist

                    I go into Projects , then under Build Steps I have tried to "Custom process step"

                    9818eb18-a42b-4fcb-bec1-042dac6485fb-image.png

                    Then I provide the following command and argument:

                    01873afc-7f3a-4539-9fd6-646601cd9f9a-image.png

                    I get the following error when trying to build the project:

                    make: *** No rule to make target `install'.  Stop.
                    15:01:39: The process "C:\Program Files (x86)\GnuWin32\bin\make.exe" exited with code 2.
                    Error while building/deploying project QtMqtt (kit: Desktop Qt 6.5.0 MinGW 64-bit)
                    When executing step "Custom Process Step"
                    15:01:39: Elapsed time: 00:00.
                    
                    

                    I also noticed that it complains about working directory:
                    72b90f93-be76-4652-af90-6bc275cc7144-image.png

                    I tried to replace it with build directory as shown below but still with little luck
                    879798b7-4246-4c2d-9bcc-aa9756621b25-image.png

                    Perhaps you know an easy method on how to setup mqtt using command line? I dont mind using command line if that is easier for you.

                    1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Check the bottom right part of this image of this stack overflow post

                      alt text

                      Just add that step and it should install the module.

                      L Offline
                      L Offline
                      lukutis222
                      wrote on last edited by lukutis222
                      #14

                      @SGaist

                      UPDATE

                      I have been experimenting with Build Steps and figured something out:

                      c5c7523f-03ef-4755-bc73-81931868a0f8-image.png

                      I have added another cmake build step and just ticked "install" Target" (See image below):
                      44bcf9a9-9476-46c1-8383-87fad0422b7a-image.png

                      After building the project, I can confirm that the MQTT module has been installed. If I go to

                      C:\Qt\6.5.0\mingw_64\modules
                      

                      I can see mqtt.json module in the folder.

                      I can now build MQTT examples! Thank you for helping me out!

                      Just out of curiosity - Do you have any ideas why this process hasnt been automated yet by QT Creator? Why is it not possible to simply run mqtt projects like any other project from the example projects? Why can I not download the MQTT module via the Maintenance tool? Why do we need to go through all the extra steps to get it running? Surely it would be more convenient and simple?

                      SGaistS 1 Reply Last reply
                      0
                      • L lukutis222

                        @SGaist

                        UPDATE

                        I have been experimenting with Build Steps and figured something out:

                        c5c7523f-03ef-4755-bc73-81931868a0f8-image.png

                        I have added another cmake build step and just ticked "install" Target" (See image below):
                        44bcf9a9-9476-46c1-8383-87fad0422b7a-image.png

                        After building the project, I can confirm that the MQTT module has been installed. If I go to

                        C:\Qt\6.5.0\mingw_64\modules
                        

                        I can see mqtt.json module in the folder.

                        I can now build MQTT examples! Thank you for helping me out!

                        Just out of curiosity - Do you have any ideas why this process hasnt been automated yet by QT Creator? Why is it not possible to simply run mqtt projects like any other project from the example projects? Why can I not download the MQTT module via the Maintenance tool? Why do we need to go through all the extra steps to get it running? Surely it would be more convenient and simple?

                        SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #15

                        @lukutis222 AFAIK, pre-built binaries for that module are available for commercial license holder.

                        As for Qt Creator, most likely because Qt Creator is way younger than Qt itself and has likely not yet been used as much as other means to develop Qt. Note that having for example the qtbase completely loaded in an IDE is a pretty intensive task which might not even be doable due to the sheer size of the module.

                        However, additional documentation on that matter would be something good.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved