Coder Social home page Coder Social logo

Comments (12)

guilhermeferreira avatar guilhermeferreira commented on August 18, 2024 1

@janoshh I guess your command is lacking the library path (-L) for the Paho MQTT C++ (-lmqttpp). You check the @prateekbansal comment above. But adding the path to libmqttpp.

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on August 18, 2024 1

The raw Makefiles now have a "make install" and the CMake/autotools deal with this properly.

from paho.mqtt.cpp.

ristomet avatar ristomet commented on August 18, 2024

Same here.

from paho.mqtt.cpp.

guilhermeferreira avatar guilhermeferreira commented on August 18, 2024

Hi Jason,

I faced the same issues. The first problem is the lack of "make install" to copy the paho-mqtt-cpp library to one of the standard paths. The second one is the handling of the dependencies. The paho-mqtt-c (C library).

Then, I started to work on two building system versions for this library, one is Autotools and the other is CMake. Those building systems address both of those problems.

The Autotools checks the existence of the libpaho-mqtta.so (the asynchronous version of the Paho C). Besides, it's possible to conditionally compile a static library version (passing --enable-static to configure), the documentation (--enable-doc) and the sample applications (--enable-samples).

$ git clone https://github.com/guilhermeferreira/paho.mqtt.cpp.git
$ git checkout -t origin/build-autotools
$ ./bootstrap
$ ./configure [options]
$ make

The CMake building system for Paho C++ was modeled after the one Rainer Poisel made to Paho C. To configure, use the "ccmake .." command inside the "build" directory. You have similar options as those for Autotools.

$ git clone https://github.com/guilhermeferreira/paho.mqtt.cpp.git
$ cd paho.mqtt.cpp
$ git checkout -t origin/build-cmake
$ mkdir build
$ cd build
$ cmake ..
$ ccmake ..

Best regards,

from paho.mqtt.cpp.

Jason-Gew avatar Jason-Gew commented on August 18, 2024

Hi,

Thanks for the suggestions above.
We checked the Makefile inside the /src/samples and utilized the c library paho-mqtt3a to compile it successfully. Not sure it's the very correct way, but at least it's working fine now.

  1. Copy 3 .so Libraries files in lib folder to /usr/local/lib.
  2. Use Paho MQTT C library paho-mqtt3a instead of the previous cpp library which can be re-edit in the Makefile.
  3. Try make the samples, it will work.

Best Regards!

from paho.mqtt.cpp.

prateekbansal avatar prateekbansal commented on August 18, 2024

For me, this worked from inside my samples directory:
LDLIBS += -L../../lib -L$(PAHO_C_LIB) -lmqttpp -lpaho-mqtt3as

where PAHO_C_LIB ?= /usr/local/lib

I am using the ssl enabled version of paho client C and have those libs installed under /usr/local/lib. For me the paho client C libs go under /usr/local/lib when I did sudo make install when I built paho client C.

from paho.mqtt.cpp.

griera avatar griera commented on August 18, 2024

I used the same approach that @prateekbansal explain above, and it works. As a prerequisite, Paho MQTT Client C must be compiled and installed properly.

from paho.mqtt.cpp.

guilhermeferreira avatar guilhermeferreira commented on August 18, 2024

I made a patch to add the "install" target (#5)

from paho.mqtt.cpp.

janoshh avatar janoshh commented on August 18, 2024

I'm having the same problem.

g++ -Dhidapi -Wall -O2 -std=gnu++11 -fpermissive src/main.cpp src/helpers/utils.cpp src/helpers/help.cpp src/helpers/help.h src/helpers/utils.h src/classes/Keyboard.cpp src/classes/Keyboard.h -o bin/g810-led -lhidapi-hidraw -l paho-mqtt3c -lmqttpp
src/main.cpp: In function ‘void onConnect(void*, MQTTAsync_successData*)’:
src/main.cpp:385:19: warning: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
pubmsg.payload = awkMsg;
^
/usr/bin/ld: cannot find -lmqttpp
collect2: error: ld returned 1 exit status

How do i add the library in the make file of my cpp project?

make file:

CC=g++
CFLAGS=-Wall -O2 -std=gnu++11 -fpermissive
LFLAGS=-l paho-mqtt3c -lmqttpp

from paho.mqtt.cpp.

janoshh avatar janoshh commented on August 18, 2024

@guilhermeferreira Allright it seems the library is found, but i'm still getting reference errors like:

/tmp/ccT57dw6.o: In function connlost(void*, char*)': main.cpp:(.text+0x284): undefined reference to MQTTAsync_connect'
/tmp/ccT57dw6.o: In function onSend(void*, MQTTAsync_successData*)': main.cpp:(.text+0x308): undefined reference to MQTTAsync_disconnect

etc..

Any idea why tis error occurs?

from paho.mqtt.cpp.

guilhermeferreira avatar guilhermeferreira commented on August 18, 2024

@janoshh it seems you are missing the -lpaho-mqtt3as. But, for accurate diagnostics, could you paste your Makefile?

from paho.mqtt.cpp.

janoshh avatar janoshh commented on August 18, 2024

Yes that did the job! I was using the paho-mqtt3c and didn't notice that there was the paho-mqtt3a etc.. thx, saved my day!

from paho.mqtt.cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.