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
    1 Dec 2023, 09:13

    @jsulm Also if I include the quotes i get lots of different errors such as 964a3e67-f886-41f2-affb-bd74bd29cd6a-image.png

    J Online
    J Online
    jsulm
    Lifetime Qt Champion
    wrote on 1 Dec 2023, 09:30 last edited by
    #6

    @Dean21 Now you get linker errors, which means you're not linking properly or the lib is not compatible because of different compiler. Did you also fix your LIBS part in pro file (quotes)?

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

    1 Reply Last reply
    0
    • D Dean21
      1 Dec 2023, 09:13

      @jsulm Also if I include the quotes i get lots of different errors such as 964a3e67-f886-41f2-affb-bd74bd29cd6a-image.png

      D Offline
      D Offline
      Dean21
      wrote on 1 Dec 2023, 09:43 last edited by
      #7

      @Dean21 Yes I also fixed the libs part in the pro file with the quotes as well.
      So what can I do to try and get it to link, the kit used when I made this project says it is Desktop Qt 6.4.1 MinGW 64-bit for the compiler.

      Thanks for the help

      J 1 Reply Last reply 1 Dec 2023, 09:56
      0
      • D Dean21
        30 Nov 2023, 22:17

        Hi, I am making a widget application in qt creator 9.0.1

        I have been stuck on this for a while now, I have previously had this library (https://github.com/KostiantynBushko/QMosqMqttClient) working on a linux computer so just tried to follow the same as I did before in the .pro file and what I put in my widget.cpp file.

        I have included the .h and .cpp file in the project as it says to do in the github instructions and included the compiler flag in my .pro file.

        And the mosquitto library is working when used by itself outside of qt

        The issue is that when I try to compile I get this error

        C:\Program Files\mosquitto\devel\mosquittopp.h:31: error: mosquitto.h: No such file or directory
        In file included from ..\Microscope_GUI\QMMqttClient.h:6,
                         from ..\Microscope_GUI\widget.cpp:12:
        C:/Program Files/mosquitto/devel/mosquittopp.h:31:10: fatal error: mosquitto.h: No such file or directory
           31 | #include <mosquitto.h>
              |          ^~~~~~~~~~~~~
        

        And the same error 2 more times for where it cant find the library.

        The mosquitto.h and mosquittopp.h are both part of the mosquitto mqtt library and are in the same directory, locate on my computer at C:\Program Files\mosquitto\devel

        The include error is saying that the mosquittopp.h file doesnt recognise mosquitto.h as a file even though they are in the same directory.

        I have tried included full path names in my widget.cpp, .pro file, the mosquittopp.h file and the mosquitto.h file but nothing seems to work.

        This is 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 += 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
        

        This is my widget.cpp file

        #include "widget.h"
        #include "ui_widget.h"
        #include <QPalette>
        #include <QDebug>
        #include <QTimer>
        #include <QString>
        
        
        //-----for qt qrapper for mosquitto-----
        #include <QCoreApplication>
        #include <QTime>
        #include "QMMqttClient.h"
        //--------------------------------------
        
        Widget::Widget(QWidget *parent)
            : QWidget(parent)
            , ui(new Ui::Widget)
        {
            ui->setupUi(this);
        }
        
        Widget::~Widget()
        {
            delete ui;
        }
        

        All other files are unaltered from the library or are automatically generated when you make a widget application.

        Any help on what I could be doing wrong would be great as I am quite stuck on this.

        S Offline
        S Offline
        starkm42
        wrote on 1 Dec 2023, 09:49 last edited by
        #8

        @Dean21 i am thinking this is because you forgot to add DEPENDPATH

        source: https://doc.qt.io/qt-6/qmake-variable-reference.html#dependpath

        Specifies a list of directories for qmake to scan, to resolve dependencies. This variable is used when qmake crawls through the header files that you #include in your source code.
        

        when using 3rd party libraries, this method is much more easy and less error prone. https://doc.qt.io/qtcreator/creator-project-qmake-libraries.html

        Qt modifies your qmake file for you.

        D 1 Reply Last reply 1 Dec 2023, 09:57
        0
        • D Dean21
          1 Dec 2023, 09:43

          @Dean21 Yes I also fixed the libs part in the pro file with the quotes as well.
          So what can I do to try and get it to link, the kit used when I made this project says it is Desktop Qt 6.4.1 MinGW 64-bit for the compiler.

          Thanks for the help

          J Online
          J Online
          jsulm
          Lifetime Qt Champion
          wrote on 1 Dec 2023, 09:56 last edited by
          #9

          @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.

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

          D 1 Reply Last reply 1 Dec 2023, 10:00
          0
          • S starkm42
            1 Dec 2023, 09:49

            @Dean21 i am thinking this is because you forgot to add DEPENDPATH

            source: https://doc.qt.io/qt-6/qmake-variable-reference.html#dependpath

            Specifies a list of directories for qmake to scan, to resolve dependencies. This variable is used when qmake crawls through the header files that you #include in your source code.
            

            when using 3rd party libraries, this method is much more easy and less error prone. https://doc.qt.io/qtcreator/creator-project-qmake-libraries.html

            Qt modifies your qmake file for you.

            D Offline
            D Offline
            Dean21
            wrote on 1 Dec 2023, 09:57 last edited by
            #10

            @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.

            J 1 Reply Last reply 1 Dec 2023, 09:59
            0
            • D Dean21
              1 Dec 2023, 09:57

              @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.

              J Online
              J Online
              jsulm
              Lifetime Qt Champion
              wrote on 1 Dec 2023, 09:59 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 1 Dec 2023, 10:00
              0
              • J jsulm
                1 Dec 2023, 09:56

                @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 1 Dec 2023, 10:00 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 1 Dec 2023, 10:24
                0
                • J jsulm
                  1 Dec 2023, 09:59

                  @Dean21 How does your pro file look like now?

                  D Offline
                  D Offline
                  Dean21
                  wrote on 1 Dec 2023, 10:00 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'
                  
                  
                  J 1 Reply Last reply 1 Dec 2023, 10:02
                  0
                  • D Dean21
                    1 Dec 2023, 10:00

                    @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'
                    
                    
                    J Online
                    J Online
                    jsulm
                    Lifetime Qt Champion
                    wrote on 1 Dec 2023, 10:02 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 1 Dec 2023, 10:05
                    0
                    • J jsulm
                      1 Dec 2023, 10:02

                      @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 1 Dec 2023, 10:05 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.

                      J 1 Reply Last reply 1 Dec 2023, 10:09
                      0
                      • D Dean21
                        1 Dec 2023, 10:05

                        @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.

                        J Online
                        J Online
                        jsulm
                        Lifetime Qt Champion
                        wrote on 1 Dec 2023, 10:09 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 1 Dec 2023, 10:14
                        0
                        • J jsulm
                          1 Dec 2023, 10:09

                          @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 1 Dec 2023, 10:14 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
                            1 Dec 2023, 10:00

                            @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 1 Dec 2023, 10:24 last edited by starkm42 12 Jan 2023, 10:25
                            #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 1 Dec 2023, 10:29
                            0
                            • S starkm42
                              1 Dec 2023, 10:24

                              @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 1 Dec 2023, 10:29 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 1 Dec 2023, 11:11 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 1 Dec 2023, 11:21
                                0
                                • D Dean21
                                  1 Dec 2023, 11:11

                                  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 1 Dec 2023, 11:21 last edited by starkm42 12 Jan 2023, 11:22
                                  #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 2 Dec 2023, 20:54
                                  0
                                  • S starkm42
                                    1 Dec 2023, 11: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 Offline
                                    D Offline
                                    Dean21
                                    wrote on 2 Dec 2023, 20:54 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

                                    15/22

                                    1 Dec 2023, 10:05

                                    • Login

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