mosquitto库交叉编译

1】下载源码:wget https://mosquitto.org/files/source/mosquitto-1.6.9.tar.gz

2】tar zxfv mosquitto-1.6.9.tar.gz

3】cd mosquitto-1.6.9

4】gedit CMakeLists.txt

在set (VERSION 1.6.9)下一行增加以下部分:
#add  ---start
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

SET(CMAKE_C_COMPILER /home/a/Downloads/neoway-arm-oe-linux/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc)

SET(CMAKE_CXX_COMPILER /home/a/Downloads/neoway-arm-oe-linux/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-g++)

set(CMAKE_SYSROOT /home/a/Downloads/neoway-arm-oe-linux/sysroots/armv7a-vfp-neon-oe-linux-gnueabi)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

include_directories(/home/a/mosquitto/mosquitto/src/deps/)
#add  ---end

5】source ~/Downloads/neoway-arm-oe-linux/neoway-env-init.sh

mkdir output

cd output

cmake ..

make

6】查看生成的库:

ls lib

将三个.so文件推到板子的/usr/lib即可, 

output/client/文件夹内有三个可执行文件mosquitto_pub,mosquitto_rr, mosquitto_sub,可拷贝到N720模块内测试。对应的源码程序在主目录client文件夹。

其中mosquitto_rr是查询应答模式

posted @ 2020-06-03 16:19  HuDaXia  阅读(3243)  评论(0编辑  收藏  举报