开发板 rk3288 + lubuntu 16.04
主机 Ubuntu16.04
编译之前可能要安装一些软件,可参考paho.mqtt.cpp文档:[https://github.com/eclipse/paho.mqtt.cpp]

openssl-OpenSSL_1_0_0-stable.zip   paho.mqtt.c-master.zip   paho.mqtt.cpp-master.zip

1.openssl

#cd openssl-OpenSSL_1_0_0-stable
#./Configure no-asm shared linux-generic32 no-async --prefix=$(pwd)/install --cross-compile-prefix=arm-linux-gnueabihf-
#make depend
#make
#make install
#ls install
bin  include  lib  ssl

关于:linux-generic32 由于 rk3288 是32位的ARM,64位的芯片可以不用设置。查看别人说要修改Makefile去掉-m64, 而使用linux-generic32一次搞定。([https://www.cnblogs.com/djw316/p/10786173.html])

2.paho.mqtt.c

#cd paho.mqtt.c
#mkdir build_arm
#cd build_arm 
#cmake ..  -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc  \
-DCMAKE_INSTALL_PREFIX=./install  \
-DPAHO_WITH_SSL=TRUE  \
-DOPENSSL_SSL_LIBRARY=/home/winston/openssl_1.0.0/openssl_arm_install/lib/libssl.so 	\
-DOPENSSL_INCLUDE_DIR=/home/winston/openssl_1.0.0/openssl_arm_install/include 	\
-DOPENSSL_CRYPTO_LIBRARY=/home/winston/openssl_1.0.0/openssl_arm_install/lib/libcrypto.so
#make 
#make install 

或者指定
-DOPENSSL_ROOT_DIR=$OPENSSL_ROOT_DIR
SET(OPENSSL_ROOT_DIR “” CACHE PATH “Directory containing OpenSSL libraries and includes”)
没有测试,感兴趣的同学自行测试
3.paho.mqtt.cpp

#cd paho.mqtt.cpp
#mkdir build_arm
#cd build_arm 
#cmake ..  -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++  \
-DCMAKE_INSTALL_PREFIX=./install  \
-DPAHO_MQTT_C_LIBRARIES=/home/winston/paho.mqtt.c/build_arm/install/lib/libpaho-mqtt3c.so.1.3.4  \
-DPAHO_MQTT_C_INCLUDE_DIRS=/home/winston/paho.mqtt.c/build_arm/install/include  \
-DOPENSSL_SSL_LIBRARY=/home/winston/openssl_1.0.0/openssl_arm_install/lib/libssl.so  \
-DOPENSSL_INCLUDE_DIR=/home/winston/openssl_1.0.0/openssl_arm_install/include  \
-DOPENSSL_CRYPTO_LIBRARY=/home/winston/openssl_1.0.0/openssl_arm_install/lib/libcrypto.so
#make 
#make install 

完成~!

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐