(mqtt学习2)编译安装paho

1,源码下载:

https://github.com/eclipse/paho.mqtt.c

解压:

guoyanzhang@debian:~/test$ unzip paho.mqtt.c-master.zip

2,安装编译用的库

guoyanzhang@debian:~/test/paho.mqtt.c-master$ sudo apt-get install build-essential gcc make cmake cmake-gui cmake-curses-gui
guoyanzhang@debian:~/test/paho.mqtt.c-master$ sudo apt-get install fakeroot fakeroot devscripts dh-make lsb-release
guoyanzhang@debian:~/test/paho.mqtt.c-master$ sudo apt-get install libssl-dev
guoyanzhang@debian:~/test/paho.mqtt.c-master$ sudo apt-get install doxygen graphviz

3,编译

guoyanzhang@debian:~/test/paho.mqtt.c-master$ make
guoyanzhang@debian:~/test/paho.mqtt.c-master$ sudo make install
guoyanzhang@debian:~/test/paho.mqtt.c-master$ make html

4,把头文件拷贝到自己要用的地方(这步根据自己的需要选择做)

guoyanzhang@debian:~/test$ cp paho.mqtt.c-master/src/MQTTAsync.h mqtt_h/
guoyanzhang@debian:~/test$ cp paho.mqtt.c-master/src/MQTTClientPersistence.h mqtt_h/
guoyanzhang@debian:~/test$ cp paho.mqtt.c-master/src/MQTTProperties.h mqtt_h/
guoyanzhang@debian:~/test$ cp paho.mqtt.c-master/src/MQTTReasonCodes.h mqtt_h/
guoyanzhang@debian:~/test$ cp paho.mqtt.c-master/src/MQTTSubscribeOpts.h mqtt_h/

5,编译的时候要用-lpaho-mqtt3a

The Paho C client comprises four shared libraries:

libmqttv3a.so - asynchronous (MQTTAsync)
libmqttv3as.so - asynchronous with SSL (MQTTAsync)
libmqttv3c.so - "classic" / synchronous (MQTTClient)
libmqttv3cs.so - "classic" / synchronous with SSL (MQTTClient)

3a是异步,3as是带ssl的异步,3c是同步,3cs是带ssl的同步。

paho是分异步函数和同步函数的,异步函数是非阻塞的,就是把消息发到broker,函数会立即返回,但是消息并未被执行,而是加入一个队列,等待执行,同步函数是阻塞的,等到消息被执行才返回。异步函数也可以加一些其它的参数变成同步阻塞,总体来说,异步函数包含同步函数。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值