明远智睿技术论坛

标题: MQTT (Mosquitto库移植) [打印本页]

作者: myzr_soft    时间: 2019-12-18 13:48
标题: MQTT (Mosquitto库移植)
主机平台: UBUNTU14.04
硬件平台:明远智睿
MY-IMX6-EK140P
内核版本 :linux-4.1.15
交叉编译链:arm-poky-linux-gnueabi
文件系统:L4115-fsl-image-qt5-myimx6a7.tar.bz2


下载:
Mosquitto库 : https://mosquitto.org/download/
openssl : https://www.openssl.org/source/openssl-1.0.2s.tar.gz
配置环境变量:
$ source my-work/03_toolchain/fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa7hf-neon-toolchain-4.1.152.1.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi
解压:
$ tar xzvf openssl-1.0.2s.tar.gz
$ tar xzvf mosquitto-1.6.8.tar.gz

编译openssl:
$ mkdir openssl
$ cd openssl-1.0.2s/
$ ./Configure --prefix=/home/myzr/openssl os/compiler:arm-poky-linux-gnueabi-gcc -fPIC
$ vi Makefile
  将CC= $(CROSS_COMPILE)arm-poky-linux-gnueabi-gcc  
  修改为CC= arm-poky-linux-gnueabi-gcc
[attach]609[/attach]

$ make
$ make install

编译mosquitto :
$ cd ../mosquitto-1.6.8/
$ vi config.mk
修改:
WITH_DOCS:=no
[attach]610[/attach]

添加:
CFLAGS += -I/home/myzr/openssl/include
LDFLAGS += -L/home/myzr/openssl/lib -lssl -lcrypto
STRIP?=arm-poky-linux-gnueabi-strip  
[attach]611[/attach]
$ make CC="gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi" CXX="g++ -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi"
$ cd lib
libmosquitto.so.1 即为编译出来的库,将其移植到开发板的/usr/lib

[attach]612[/attach]




欢迎光临 明远智睿技术论坛 (http://bbs.myzr.com.cn/) Powered by Discuz! X3.2