Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Missing MQTT source file after installation
QtWS25 Last Chance

Missing MQTT source file after installation

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 4 Posters 910 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.
  • D Offline
    D Offline
    diego-qt
    wrote on last edited by
    #1

    Hello,

    So I am trying to make a project involving a MQTT communication between two devices. I followed some guidelines from the internet that made me do this:

    cd ~/qt5
    git clone https://github.com/qt/qtmqtt.git --branch 5.15
    cd ~/qt-build
    mkdir qtmqtt && cd qtmqtt
    sudo /opt/Qt5.15/qmake ~/qt5/qtmqtt/qtmqtt.pro
    sudo make
    sudo make install
    

    Basically, I cloned the Qt MQTT repository into the existing Qt5 cloned repository I had, then I turned to the build directory and launched qmake for the .pro file, make and make install.

    I tried setting up a project of my own with the help of the existing Qt examples. I had some difficulties but I figured out that I had to invoke almost every MQTT source file into the CMakeLists. However, I found a dead end when I saw that I had no qmqttstringpair.cpp file.

    /opt/Qt5.15/include/QtCore/qvector.h:355: erreur : undefined reference to `QMqttStringPair::QMqttStringPair(QMqttStringPair const&)'
    

    As a matter of fact, I searched and found the header and source files for all the other classes somewhere in my computer, but for QMqttStringPair I wasn't able to find its them. I find it weird and I don't know if I missed something or there was a problem with the Makefile or installation. I also couldn't find clues in the web.

    I am using an Ubuntu 22.04
    Thanks for your help.

    SGaistS JoeCFDJ O 3 Replies Last reply
    0
    • D diego-qt

      Hello,

      So I am trying to make a project involving a MQTT communication between two devices. I followed some guidelines from the internet that made me do this:

      cd ~/qt5
      git clone https://github.com/qt/qtmqtt.git --branch 5.15
      cd ~/qt-build
      mkdir qtmqtt && cd qtmqtt
      sudo /opt/Qt5.15/qmake ~/qt5/qtmqtt/qtmqtt.pro
      sudo make
      sudo make install
      

      Basically, I cloned the Qt MQTT repository into the existing Qt5 cloned repository I had, then I turned to the build directory and launched qmake for the .pro file, make and make install.

      I tried setting up a project of my own with the help of the existing Qt examples. I had some difficulties but I figured out that I had to invoke almost every MQTT source file into the CMakeLists. However, I found a dead end when I saw that I had no qmqttstringpair.cpp file.

      /opt/Qt5.15/include/QtCore/qvector.h:355: erreur : undefined reference to `QMqttStringPair::QMqttStringPair(QMqttStringPair const&)'
      

      As a matter of fact, I searched and found the header and source files for all the other classes somewhere in my computer, but for QMqttStringPair I wasn't able to find its them. I find it weird and I don't know if I missed something or there was a problem with the Makefile or installation. I also couldn't find clues in the web.

      I am using an Ubuntu 22.04
      Thanks for your help.

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

      Hi,

      There's something fishy here: why does that error occur in the QVector header ?

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

      D 1 Reply Last reply
      0
      • D diego-qt

        Hello,

        So I am trying to make a project involving a MQTT communication between two devices. I followed some guidelines from the internet that made me do this:

        cd ~/qt5
        git clone https://github.com/qt/qtmqtt.git --branch 5.15
        cd ~/qt-build
        mkdir qtmqtt && cd qtmqtt
        sudo /opt/Qt5.15/qmake ~/qt5/qtmqtt/qtmqtt.pro
        sudo make
        sudo make install
        

        Basically, I cloned the Qt MQTT repository into the existing Qt5 cloned repository I had, then I turned to the build directory and launched qmake for the .pro file, make and make install.

        I tried setting up a project of my own with the help of the existing Qt examples. I had some difficulties but I figured out that I had to invoke almost every MQTT source file into the CMakeLists. However, I found a dead end when I saw that I had no qmqttstringpair.cpp file.

        /opt/Qt5.15/include/QtCore/qvector.h:355: erreur : undefined reference to `QMqttStringPair::QMqttStringPair(QMqttStringPair const&)'
        

        As a matter of fact, I searched and found the header and source files for all the other classes somewhere in my computer, but for QMqttStringPair I wasn't able to find its them. I find it weird and I don't know if I missed something or there was a problem with the Makefile or installation. I also couldn't find clues in the web.

        I am using an Ubuntu 22.04
        Thanks for your help.

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #3

        @diego-qt after build, you link the lib of qt mqtt module to your app. Why do you need .cpp files?

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          There's something fishy here: why does that error occur in the QVector header ?

          D Offline
          D Offline
          diego-qt
          wrote on last edited by
          #4

          Hi,

          @SGaist the error doesn't only appear in that header but in QMqttConnection.cpp too. 15 in total for both files. The two files must be calling QMqttStringPair in their code.

          /usr/bin/ld: CMakeFiles/PCDisplay.dir/home/diego/qt5/qtmqtt/src/mqtt/qmqttconnection.cpp.o: in function `QMqttConnection::readAuthProperties(QMqttAuthenticationProperties&)':
          /home/diego/qt5/qtmqtt/src/mqtt/qmqttconnection.cpp:807: undefined reference to `QMqttStringPair::QMqttStringPair(QString const&, QString const&)'
          /usr/bin/ld: /home/diego/qt5/qtmqtt/src/mqtt/qmqttconnection.cpp:807: undefined reference to `QMqttStringPair::~QMqttStringPair()'
          
          /usr/bin/ld: CMakeFiles/PCDisplay.dir/home/diego/qt5/qtmqtt/src/mqtt/qmqttconnection.cpp.o: in function `QMqttConnection::readConnackProperties(QMqttServerConnectionProperties&)':
          /home/diego/qt5/qtmqtt/src/mqtt/qmqttconnection.cpp:882: undefined reference to `QMqttStringPair::QMqttStringPair(QString const&, QString const&)'
          /usr/bin/ld: /home/diego/qt5/qtmqtt/src/mqtt/qmqttconnection.cpp:882: undefined reference to `QMqttStringPair::~QMqttStringPair()'
          
          /usr/bin/ld: CMakeFiles/PCDisplay.dir/home/diego/qt5/qtmqtt/src/mqtt/qmqttconnection.cpp.o: in function `QVector<QMqttStringPair>::copyConstruct(QMqttStringPair const*, QMqttStringPair const*, QMqttStringPair*)':
          /opt/Qt5.15/include/QtCore/qvector.h:355: undefined reference to `QMqttStringPair::QMqttStringPair(QMqttStringPair const&)'
          ...
          

          @JoeCFD right now I'm not sure if the build placed the files in the right place.
          In /opt/Qt5.15/include/QtMqtt I have the headers and some other "C code source" files (that I haven't seen before) that only contain something like

          #include "qmqttauthenticationproperties.h"
          

          and that's it.
          The errors I have are undefined reference so I thought I had to link the cpp files which were installed in ~/qt5/mqtt/src/mqtt
          Am I doing something wrong?

          1 Reply Last reply
          0
          • D diego-qt

            Hello,

            So I am trying to make a project involving a MQTT communication between two devices. I followed some guidelines from the internet that made me do this:

            cd ~/qt5
            git clone https://github.com/qt/qtmqtt.git --branch 5.15
            cd ~/qt-build
            mkdir qtmqtt && cd qtmqtt
            sudo /opt/Qt5.15/qmake ~/qt5/qtmqtt/qtmqtt.pro
            sudo make
            sudo make install
            

            Basically, I cloned the Qt MQTT repository into the existing Qt5 cloned repository I had, then I turned to the build directory and launched qmake for the .pro file, make and make install.

            I tried setting up a project of my own with the help of the existing Qt examples. I had some difficulties but I figured out that I had to invoke almost every MQTT source file into the CMakeLists. However, I found a dead end when I saw that I had no qmqttstringpair.cpp file.

            /opt/Qt5.15/include/QtCore/qvector.h:355: erreur : undefined reference to `QMqttStringPair::QMqttStringPair(QMqttStringPair const&)'
            

            As a matter of fact, I searched and found the header and source files for all the other classes somewhere in my computer, but for QMqttStringPair I wasn't able to find its them. I find it weird and I don't know if I missed something or there was a problem with the Makefile or installation. I also couldn't find clues in the web.

            I am using an Ubuntu 22.04
            Thanks for your help.

            O Offline
            O Offline
            oniongarlic
            wrote on last edited by
            #5

            @diego-qt said in Missing MQTT source file after installation:

            Basically, I cloned the Qt MQTT repository into the existing Qt5 cloned repository I had, then I turned to the build directory and launched qmake for the .pro file, make and make

            Just in case, try to clone it outside Qt 5 source for a start, who knows what it picks up.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              diego-qt
              wrote on last edited by
              #6

              Hello, I'll be posting the solution I found.

              First of all, I indeed didn't need to add the .cpp files to the CMakeLists file. The proper solution was to add

              find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Mqtt REQUIRED)
              target_link_libraries(mytarget PRIVATE Qt${QT_VERSION_MAJOR}::Mqtt)
              

              Because the librairies were already installed, I only had to invoke them.

              But further than that, I also had to compile the .pro file of the qtmqtt repository with the qmake tool from the system, otherwise the MQTT libraries will only be visible for the Qt for Android compiler and not the desktop compiler. Also, it would be better to compile it outside of the build directory just used.

              1 Reply Last reply
              0
              • D diego-qt has marked this topic as solved on

              • Login

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