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. Find Package Failed for MQTT Simple Application
QtWS25 Last Chance

Find Package Failed for MQTT Simple Application

Scheduled Pinned Locked Moved Solved General and Desktop
mqtt
8 Posts 2 Posters 1.5k Views
  • 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.
  • X Offline
    X Offline
    xpress_embedo
    wrote on 21 Jan 2023, 07:20 last edited by
    #1

    Hello Everyone,
    I wanted to test the simple MQTT application from the example project.
    But things are not working well for me.
    As per the documentation, available on this https://doc.qt.io/qt-6.2/qtmqtt-index.html page.
    I have to use the following in my CMakeLists.txt file, and I updated my file as below.

    cmake_minimum_required(VERSION 3.16)
    
    project(MQTT_Application VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(Qt6 6.2 COMPONENTS Quick REQUIRED)
    find_package(Qt6 REQUIRED COMPONENTS Mqtt)
    
    qt_add_executable(appMQTT_Application
        main.cpp
    )
    
    qt_add_qml_module(appMQTT_Application
        URI MQTT_Application
        VERSION 1.0
        QML_FILES main.qml 
    )
    
    set_target_properties(appMQTT_Application PROPERTIES
        MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
    )
    
    target_link_libraries(appMQTT_Application
        PRIVATE Qt6::Quick)
    
    target_link_libraries(appMQTT_Application
        PRIVATE Qt6::Mqtt)
    
    install(TARGETS appMQTT_Application
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
    
    

    But, I am getting the following error.

    /home/xpress_embedo/Work/ESP32/ControlDevicesMQTT/MQTT_Application/CMakeLists.txt:9: error: Found package configuration file: /opt/Qt/6.2.4/gcc_64/lib/cmake/Qt6/Qt6Config.cmake but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT FOUND.  Reason given by package: Failed to find Qt component "Mqtt". Expected Config file at "/opt/Qt/6.2.4/gcc_64/lib/cmake/Qt6Mqtt/Qt6MqttConfig.cmake" does NOT exist```
    
    As can be seen in the above logs, the Qt version is 6.2.4
    Can someone help me with this issue?
    1 Reply Last reply
    0
    • S SGaist
      23 Jan 2023, 19:35
      1. the path I used in my example above was on purpose. Look into your Qt 6.2.4 folder, you'll find qt-cmake in the bin folder. That would have avoided the round trip through Qt Creator. Note that it's not wrong to use Qt Creator at all, I am just used to the terminal.
      2. Either add a custom step that calls cmake install or do it on the terminal as shown above.
      3. the instructions in the documentation are for using the module and are correct from that point of view.
      X Offline
      X Offline
      xpress_embedo
      wrote on 23 Jan 2023, 21:49 last edited by xpress_embedo
      #7

      @SGaist Thank You for your answer. I still find it difficult, but finally, I am able to fix this, with your help and some help from StackOverflow.
      I am pasting the link which helps me below.
      https://stackoverflow.com/questions/68928310/build-specific-modules-in-qt6-i-e-qtmqtt/71984521?noredirect=1#comment132724929_71984521

      One Question, on the documentation page, 4 examples are given, from where can I download them?

      This video can help others
      https://youtu.be/DGB0GfFRqPo
      And also the below-mentioned link.
      https://embeddedlaboratory.blogspot.com/2023/01/getting-started-with-mqtt-using-qt.html

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 21 Jan 2023, 20:14 last edited by SGaist
        #2

        Hi,

        Did you build and install the module before using it ?

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

        X 1 Reply Last reply 21 Jan 2023, 22:01
        0
        • S SGaist
          21 Jan 2023, 20:14

          Hi,

          Did you build and install the module before using it ?

          X Offline
          X Offline
          xpress_embedo
          wrote on 21 Jan 2023, 22:01 last edited by
          #3

          @SGaist Sorry I am new to Qt, I have not done anything except the steps which is shared on the documentation page.
          Can you please share the documentation or some steps how to do it?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 22 Jan 2023, 19:50 last edited by
            #4

            Usual cmake build commands:

            mkdir build_qtmqtt
            cd build_qtmqtt
            /path/to/Qt6/bin/qt-cmake /path/to/qtmqtt_sources/
            /path/to/Qt6/bin/qt-cmake -build . -parallel
            /path/to/Qt6/bin/qt-cmake install
            

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

            X 1 Reply Last reply 23 Jan 2023, 19:17
            2
            • S SGaist
              22 Jan 2023, 19:50

              Usual cmake build commands:

              mkdir build_qtmqtt
              cd build_qtmqtt
              /path/to/Qt6/bin/qt-cmake /path/to/qtmqtt_sources/
              /path/to/Qt6/bin/qt-cmake -build . -parallel
              /path/to/Qt6/bin/qt-cmake install
              
              X Offline
              X Offline
              xpress_embedo
              wrote on 23 Jan 2023, 19:17 last edited by
              #5

              @SGaist said in Find Package Failed for MQTT Simple Application:

              Usual cmake build commands:

              mkdir build_qtmqtt
              cd build_qtmqtt
              /path/to/Qt6/bin/qt-cmake /path/to/qtmqtt_sources/
              /path/to/Qt6/bin/qt-cmake -build . -parallel
              /path/to/Qt6/bin/qt-cmake install
              

              Thank You for some hints, I have a very basic understanding of CMake, and I will share what I have done till now, and maybe you can give me some more hints to fix my problem.
              Qt MQTT module link is this: https://code.qt.io/cgit/qt/qtmqtt.git/
              As a first step, I cloned this module using the command git clone https://code.qt.io/cgit/qt/qtmqtt.git, and after cloning I switched to branch 6.2.4, as this is the Qt version installed on my laptop.
              I opened the terminal and tried to configure the project using the following command.

              mkdir build
              cd build
              /opt/Qt/Tools/CMake/bin/cmake ..
              

              And I get the following error, also shown in the screenshot below.

              CMake Error at CMakeLists.txt:19 (find_package):
                Could not find a package configuration file provided by "Qt6" (requested
                version 6.2.4) with any of the following names:
              
                  Qt6Config.cmake
                  qt6-config.cmake
              
                Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR"
                to a directory containing one of the above files.  If "Qt6" provides a
                separate development package or SDK, be sure it has been installed.
              
              
              -- Configuring incomplete, errors occurred!
              See also "/home/xpress_embedo/Work/Qt/DontCommit/qtmqtt/build/CMakeFiles/CMakeOutput.log".
              
              

              e0e94538-822b-4887-b8fa-c16bb4badadd-image.png
              From the message, it is clear that qt6-config.cmake is missing, and I think the reason is obvious, as I have to provide the path of this.
              Anyways, as a next step, what I did is, I opened the project in QtCreator and builds it and it build properly.
              9f80b6bd-3034-4f83-ba45-1aa0961d9385-image.png

              As per the message the library is created successfully.
              [31/31 4.1/sec] Creating library symlink lib/libQt6Mqtt.so.6 lib/libQt6Mqtt.so
              I think CMake is also going to do the same thing, but what are the next steps, how can I use this library?
              Another question is why the steps mentioned in the documentation page is different.
              https://doc.qt.io/qt-6/qtmqtt-index.html

              Sorry for stupid questions, I am trying to learn.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 23 Jan 2023, 19:35 last edited by
                #6
                1. the path I used in my example above was on purpose. Look into your Qt 6.2.4 folder, you'll find qt-cmake in the bin folder. That would have avoided the round trip through Qt Creator. Note that it's not wrong to use Qt Creator at all, I am just used to the terminal.
                2. Either add a custom step that calls cmake install or do it on the terminal as shown above.
                3. the instructions in the documentation are for using the module and are correct from that point of view.

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

                X 1 Reply Last reply 23 Jan 2023, 21:49
                2
                • S SGaist
                  23 Jan 2023, 19:35
                  1. the path I used in my example above was on purpose. Look into your Qt 6.2.4 folder, you'll find qt-cmake in the bin folder. That would have avoided the round trip through Qt Creator. Note that it's not wrong to use Qt Creator at all, I am just used to the terminal.
                  2. Either add a custom step that calls cmake install or do it on the terminal as shown above.
                  3. the instructions in the documentation are for using the module and are correct from that point of view.
                  X Offline
                  X Offline
                  xpress_embedo
                  wrote on 23 Jan 2023, 21:49 last edited by xpress_embedo
                  #7

                  @SGaist Thank You for your answer. I still find it difficult, but finally, I am able to fix this, with your help and some help from StackOverflow.
                  I am pasting the link which helps me below.
                  https://stackoverflow.com/questions/68928310/build-specific-modules-in-qt6-i-e-qtmqtt/71984521?noredirect=1#comment132724929_71984521

                  One Question, on the documentation page, 4 examples are given, from where can I download them?

                  This video can help others
                  https://youtu.be/DGB0GfFRqPo
                  And also the below-mentioned link.
                  https://embeddedlaboratory.blogspot.com/2023/01/getting-started-with-mqtt-using-qt.html

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 24 Jan 2023, 08:50 last edited by
                    #8

                    They are in the sources you already cloned.

                    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
                    2

                    5/8

                    23 Jan 2023, 19:17

                    • Login

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