so I am wanting to interface the mosquitto mqtt library into qt creator (c++), to create a graphical program for using mqtt. I am trying to figure out how to add the -lmosquitto compiler option, I have seen similar posts about adding c++ compiler options by using line shown below inside the .pro file
QMAKE_CXXFLAGS += compiler option here
I tried to add the -lmosquitto compiler option in the same way shown below
QMAKE_CXXFLAGS += -lmosquitto
but I still get errors saying undefined reference to 'function names'
Does anyone know how to add compiler options for libraries into qt
FYI: I am using ubuntu, in qt creator I am creating widget application, and I am sure the -lmosquitto is the correct option as I can compile code wrote in text editor from command line using it.
Any help with this would be great,
Thanks in advance, Dean
As a general advice I would give you is, to use CMake
with QT
. QT
supports CMake
since QT5
IIRC, and since QT6
it is the standard build tool if I'm not mistaken. The benefit of using CMake
is that you will find more answers to your questions.
That being said, if you still wish to use qmake
instead of CMake
then last I checked, you will need to add a line like this to your .pro
file:
LIBS += -L/path/to/your/mosquitto_library -lmosquitto
Notice the -L
flag where you specify the library path. This is essentially what is missing from your CXX
flags.