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. Including MQTT wrapper for mosquitto library on windows

Including MQTT wrapper for mosquitto library on windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
mqttlibrarywidgetc++17
22 Posts 4 Posters 3.0k 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 Dean21

    @starkm42 Thanks for the reply, that seemed to work to remove a lot of the linking errors but not I get this one error I havent seen before

    :-1: error: No rule to make target 'C:/Users/deanm/Desktop/Uni_Year_3/3rd_year_project/Microscope_GUI_V2/Microscope_GUI/../../../../../../../Program Files/mosquitto/devel/libmosquittoppd.a', needed by 'debug/Microscope_GUI.exe'. Stop.

    jsulmJ Online
    jsulmJ Online
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #11

    @Dean21 How does your pro file look like now?

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

    D 1 Reply Last reply
    0
    • jsulmJ jsulm

      @Dean21 I think on Windows you need to link differently (see https://doc.qt.io/qt-6/qmake-variable-reference.html#libs):

      unix:LIBS += -L/usr/local/lib -lmath
      win32:LIBS += c:/mylibs/math.lib
      

      So, you need to use a path to the *.lib file of the library.

      "the kit used when I made this project says it is Desktop Qt 6.4.1 MinGW 64-bit for the compiler" - the question is - what compiler was used to build that library? If MSVC was used it is not going to work. You need a MinGW build of the lib.

      D Offline
      D Offline
      Dean21
      wrote on last edited by
      #12

      @jsulm I am not sure what compiler was used to compile the library, but as I have had this working in Qt creator before on linux with the same library I assumed it would work fine on windows

      S 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Dean21 How does your pro file look like now?

        D Offline
        D Offline
        Dean21
        wrote on last edited by
        #13

        @jsulm This is now my .pro file.

        QT       += core gui
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        CONFIG += c++17
        
        #QMAKE_CXXFLAGS += -lmosquitto
        
        #INCLUDEPATH += "C:/Program Files/mosquitto/devel"
        
        #LIBS += -L"C:/Program Files/mosquitto/devel" -lmosquittopp
        
        # You can make your code fail to compile if it uses deprecated APIs.
        # In order to do so, uncomment the following line.
        #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
        
        SOURCES += \
            QMMqttClient.cpp \
            main.cpp \
            widget.cpp \
        
        HEADERS += \
            QMMqttClient.h \
            widget.h
        
        FORMS += \
            widget.ui
        
        # Default rules for deployment.
        qnx: target.path = /tmp/$${TARGET}/bin
        else: unix:!android: target.path = /opt/$${TARGET}/bin
        !isEmpty(target.path): INSTALLS += target
        
        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/mosquitto/devel/' -lmosquittopp
        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/mosquitto/devel/' -lmosquittoppd
        else:unix: LIBS += -L$$PWD/'../../../../../../../Program Files/mosquitto/devel/' -lmosquittopp
        
        INCLUDEPATH += $$PWD/'../../../../../../../Program Files/mosquitto/devel'
        DEPENDPATH += $$PWD/'../../../../../../../Program Files/mosquitto/devel'
        
        win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittopp.a'
        else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittoppd.a'
        else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/mosquittopp.lib'
        else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/mosquittoppd.lib'
        else:unix: PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittopp.a'
        
        
        jsulmJ 1 Reply Last reply
        0
        • D Dean21

          @jsulm This is now my .pro file.

          QT       += core gui
          
          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
          
          CONFIG += c++17
          
          #QMAKE_CXXFLAGS += -lmosquitto
          
          #INCLUDEPATH += "C:/Program Files/mosquitto/devel"
          
          #LIBS += -L"C:/Program Files/mosquitto/devel" -lmosquittopp
          
          # You can make your code fail to compile if it uses deprecated APIs.
          # In order to do so, uncomment the following line.
          #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
          
          SOURCES += \
              QMMqttClient.cpp \
              main.cpp \
              widget.cpp \
          
          HEADERS += \
              QMMqttClient.h \
              widget.h
          
          FORMS += \
              widget.ui
          
          # Default rules for deployment.
          qnx: target.path = /tmp/$${TARGET}/bin
          else: unix:!android: target.path = /opt/$${TARGET}/bin
          !isEmpty(target.path): INSTALLS += target
          
          win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/mosquitto/devel/' -lmosquittopp
          else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/mosquitto/devel/' -lmosquittoppd
          else:unix: LIBS += -L$$PWD/'../../../../../../../Program Files/mosquitto/devel/' -lmosquittopp
          
          INCLUDEPATH += $$PWD/'../../../../../../../Program Files/mosquitto/devel'
          DEPENDPATH += $$PWD/'../../../../../../../Program Files/mosquitto/devel'
          
          win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittopp.a'
          else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittoppd.a'
          else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/mosquittopp.lib'
          else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/mosquittoppd.lib'
          else:unix: PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittopp.a'
          
          
          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #14

          @Dean21 said in Including MQTT wrapper for mosquitto library on windows:

          else:unix: PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittopp.a'

          Why do you have this?
          Your LIBS for Windows are still wrong.

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

          D 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Dean21 said in Including MQTT wrapper for mosquitto library on windows:

            else:unix: PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittopp.a'

            Why do you have this?
            Your LIBS for Windows are still wrong.

            D Offline
            D Offline
            Dean21
            wrote on last edited by
            #15

            @jsulm Sorry forgot to untick linux and mac boxes, here is the .pro file, it still has the same error though.

            QT       += core gui
            
            greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
            
            CONFIG += c++17
            
            QMAKE_CXXFLAGS += -lmosquitto
            
            INCLUDEPATH += "C:/Program Files/mosquitto/devel"
            
            LIBS += -L"C:/Program Files/mosquitto/devel" -lmosquittopp
            
            # You can make your code fail to compile if it uses deprecated APIs.
            # In order to do so, uncomment the following line.
            #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
            
            SOURCES += \
                QMMqttClient.cpp \
                main.cpp \
                widget.cpp \
            
            HEADERS += \
                QMMqttClient.h \
                widget.h
            
            FORMS += \
                widget.ui
            
            # Default rules for deployment.
            qnx: target.path = /tmp/$${TARGET}/bin
            else: unix:!android: target.path = /opt/$${TARGET}/bin
            !isEmpty(target.path): INSTALLS += target
            
            win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/mosquitto/devel/' -lmosquittopp
            else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/mosquitto/devel/' -lmosquittoppd
            
            INCLUDEPATH += $$PWD/'../../../../../../../Program Files/mosquitto/devel'
            DEPENDPATH += $$PWD/'../../../../../../../Program Files/mosquitto/devel'
            
            win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittopp.a'
            else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittoppd.a'
            else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/mosquittopp.lib'
            else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/mosquittoppd.lib'
            
            

            Error: :-1: error: No rule to make target 'C:/Users/deanm/Desktop/Uni_Year_3/3rd_year_project/Microscope_GUI_V2/Microscope_GUI/../../../../../../../Program Files/mosquitto/devel/libmosquittoppd.a', needed by 'debug/Microscope_GUI.exe'. Stop.

            jsulmJ 1 Reply Last reply
            0
            • D Dean21

              @jsulm Sorry forgot to untick linux and mac boxes, here is the .pro file, it still has the same error though.

              QT       += core gui
              
              greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
              
              CONFIG += c++17
              
              QMAKE_CXXFLAGS += -lmosquitto
              
              INCLUDEPATH += "C:/Program Files/mosquitto/devel"
              
              LIBS += -L"C:/Program Files/mosquitto/devel" -lmosquittopp
              
              # You can make your code fail to compile if it uses deprecated APIs.
              # In order to do so, uncomment the following line.
              #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
              
              SOURCES += \
                  QMMqttClient.cpp \
                  main.cpp \
                  widget.cpp \
              
              HEADERS += \
                  QMMqttClient.h \
                  widget.h
              
              FORMS += \
                  widget.ui
              
              # Default rules for deployment.
              qnx: target.path = /tmp/$${TARGET}/bin
              else: unix:!android: target.path = /opt/$${TARGET}/bin
              !isEmpty(target.path): INSTALLS += target
              
              win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/mosquitto/devel/' -lmosquittopp
              else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/mosquitto/devel/' -lmosquittoppd
              
              INCLUDEPATH += $$PWD/'../../../../../../../Program Files/mosquitto/devel'
              DEPENDPATH += $$PWD/'../../../../../../../Program Files/mosquitto/devel'
              
              win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittopp.a'
              else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittoppd.a'
              else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/mosquittopp.lib'
              else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/mosquittoppd.lib'
              
              

              Error: :-1: error: No rule to make target 'C:/Users/deanm/Desktop/Uni_Year_3/3rd_year_project/Microscope_GUI_V2/Microscope_GUI/../../../../../../../Program Files/mosquitto/devel/libmosquittoppd.a', needed by 'debug/Microscope_GUI.exe'. Stop.

              jsulmJ Online
              jsulmJ Online
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #16

              @Dean21 said in Including MQTT wrapper for mosquitto library on windows:

              QMAKE_CXXFLAGS += -lmosquitto

              Why?

              And again: your LIBS for Windows are wrong!

              I also don't know why you have static versions if you want to link dynamically:

              else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittoppd.a'
              

              Remove alls these *.a stuff.

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

              D 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Dean21 said in Including MQTT wrapper for mosquitto library on windows:

                QMAKE_CXXFLAGS += -lmosquitto

                Why?

                And again: your LIBS for Windows are wrong!

                I also don't know why you have static versions if you want to link dynamically:

                else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../../Program Files/mosquitto/devel/libmosquittoppd.a'
                

                Remove alls these *.a stuff.

                D Offline
                D Offline
                Dean21
                wrote on last edited by
                #17

                @jsulm My bad, this was done with dynamic and this is what was generated in the .pro file now.

                QT       += core gui
                
                greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                
                CONFIG += c++17
                
                QMAKE_CXXFLAGS += -lmosquitto
                
                INCLUDEPATH += "C:/Program Files/mosquitto/devel"
                
                LIBS += -L"C:/Program Files/mosquitto/devel" -lmosquittopp
                
                # You can make your code fail to compile if it uses deprecated APIs.
                # In order to do so, uncomment the following line.
                #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                
                SOURCES += \
                    QMMqttClient.cpp \
                    main.cpp \
                    widget.cpp \
                
                HEADERS += \
                    QMMqttClient.h \
                    widget.h
                
                FORMS += \
                    widget.ui
                
                # Default rules for deployment.
                qnx: target.path = /tmp/$${TARGET}/bin
                else: unix:!android: target.path = /opt/$${TARGET}/bin
                !isEmpty(target.path): INSTALLS += target
                
                win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/mosquitto/devel/' -lmosquittopp
                else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/mosquitto/devel/' -lmosquittoppd
                
                INCLUDEPATH += $$PWD/'../../../../../../../Program Files/mosquitto/devel'
                DEPENDPATH += $$PWD/'../../../../../../../Program Files/mosquitto/devel'
                
                

                This now gives these errors:

                :-1: error: cannot find -lmosquittoppd
                :-1: error: cannot find -lmosquittod
                :-1: error: collect2.exe: error: ld returned 1 exit status

                1 Reply Last reply
                0
                • D Dean21

                  @jsulm I am not sure what compiler was used to compile the library, but as I have had this working in Qt creator before on linux with the same library I assumed it would work fine on windows

                  S Offline
                  S Offline
                  starkm42
                  wrote on last edited by starkm42
                  #18

                  @Dean21 wait are you using the same compiled library that you used for linux on windows without recompiling or getting new binaries compiled for windows ?

                  @Dean21 said in Including MQTT wrapper for mosquitto library on windows:

                  @jsulm I am not sure what compiler was used to compile the library, but as I have had this working in Qt creator before on linux with the same library I assumed it would work fine on windows

                  D 1 Reply Last reply
                  0
                  • S starkm42

                    @Dean21 wait are you using the same compiled library that you used for linux on windows without recompiling or getting new binaries compiled for windows ?

                    @Dean21 said in Including MQTT wrapper for mosquitto library on windows:

                    @jsulm I am not sure what compiler was used to compile the library, but as I have had this working in Qt creator before on linux with the same library I assumed it would work fine on windows

                    D Offline
                    D Offline
                    Dean21
                    wrote on last edited by
                    #19

                    @starkm42 No, i just redownloaded the library from the website and set it up to start with to make sure it was working before i tried to use it in qt

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      Dean21
                      wrote on last edited by
                      #20

                      I just re-added the library, but removed the tickbox for "add d suffix for debug", and that removes the errors about finding -mosquitoppd, but now I have all the same linker errors again.

                      S 1 Reply Last reply
                      0
                      • D Dean21

                        I just re-added the library, but removed the tickbox for "add d suffix for debug", and that removes the errors about finding -mosquitoppd, but now I have all the same linker errors again.

                        S Offline
                        S Offline
                        starkm42
                        wrote on last edited by starkm42
                        #21

                        @Dean21

                        for adding a test library called NemaTode, after following the guide https://doc.qt.io/qtcreator/creator-project-qmake-libraries.html

                        this is what my qmake looks like

                        QT       += core gui positioning
                        
                        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                        
                        CONFIG += c++17
                        
                        # You can make your code fail to compile if it uses deprecated APIs.
                        # In order to do so, uncomment the following line.
                        #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                        
                        SOURCES += \
                            gpssource.cpp \
                            main.cpp \
                            mainwindow.cpp
                        
                        HEADERS += \
                            gpssource.h \
                            mainwindow.h
                        
                        # Default rules for deployment.
                        qnx: target.path = /tmp/$${TARGET}/bin
                        else: unix:!android: target.path = /opt/$${TARGET}/bin
                        !isEmpty(target.path): INSTALLS += target
                        
                        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../third_party_libs/NemaTode/lib/ -lNemaTode
                        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../third_party_libs/NemaTode/lib/ -lNemaTode
                        else:unix: LIBS += -L$$PWD/../../third_party_libs/NemaTode/lib/ -lNemaTode
                        
                        INCLUDEPATH += $$PWD/../../third_party_libs/NemaTode/include/nmeaparse
                        DEPENDPATH += $$PWD/../../third_party_libs/NemaTode/include/nmeaparse
                        
                        FORMS += \
                            GPSCordinatesDisplay.ui
                        

                        mine does not have LIB or INCLUDEPATH
                        try removing all manual additions, just sticking to the guide would be my suggestion.

                        D 1 Reply Last reply
                        0
                        • S starkm42

                          @Dean21

                          for adding a test library called NemaTode, after following the guide https://doc.qt.io/qtcreator/creator-project-qmake-libraries.html

                          this is what my qmake looks like

                          QT       += core gui positioning
                          
                          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                          
                          CONFIG += c++17
                          
                          # You can make your code fail to compile if it uses deprecated APIs.
                          # In order to do so, uncomment the following line.
                          #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                          
                          SOURCES += \
                              gpssource.cpp \
                              main.cpp \
                              mainwindow.cpp
                          
                          HEADERS += \
                              gpssource.h \
                              mainwindow.h
                          
                          # Default rules for deployment.
                          qnx: target.path = /tmp/$${TARGET}/bin
                          else: unix:!android: target.path = /opt/$${TARGET}/bin
                          !isEmpty(target.path): INSTALLS += target
                          
                          win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../third_party_libs/NemaTode/lib/ -lNemaTode
                          else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../third_party_libs/NemaTode/lib/ -lNemaTode
                          else:unix: LIBS += -L$$PWD/../../third_party_libs/NemaTode/lib/ -lNemaTode
                          
                          INCLUDEPATH += $$PWD/../../third_party_libs/NemaTode/include/nmeaparse
                          DEPENDPATH += $$PWD/../../third_party_libs/NemaTode/include/nmeaparse
                          
                          FORMS += \
                              GPSCordinatesDisplay.ui
                          

                          mine does not have LIB or INCLUDEPATH
                          try removing all manual additions, just sticking to the guide would be my suggestion.

                          D Offline
                          D Offline
                          Dean21
                          wrote on last edited by
                          #22

                          @starkm42 Thanks for the reply, the issue was to do with the fact mosquitto was compiled with a different library. To avoid this I am just going to run a ubuntu VM Thanks everyone for the help.

                          1 Reply Last reply
                          1

                          • Login

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