【随笔记】Tina 移植 Mosquitto v2.0.18 版本

移植过程

  1. 从官方源码库里面找到最新的版本 v2.0.18 并下载下来计算 md5 值

    https://mosquitto.org/files/source/mosquitto-2.0.18.tar.gz

  2. 修改顶层 Makefie:package\network\mosquitto\Makefile

    shell 复制代码
     PKG_NAME:=mosquitto
    -PKG_VERSION:=1.4.8
    +PKG_VERSION:=2.0.18
     PKG_RELEASE:=1
     PKG_LICENSE:=BSD-3-Clause
     PKG_LICENSE_FILES:=LICENSE.txt
     
     PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
     PKG_SOURCE_URL:=http://mosquitto.org/files/source/
    -PKG_MD5SUM:=d859cd474ffa61a6197bdabe007b9027
    +PKG_MD5SUM:=7fe95d0bef1aacd291d21d7752fbd21b
     PKG_BUILD_DIR:=$(COMPILE_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
  3. 编译提示没有找到 cJSON.h 文件,两种解法,要么增加 cJSON 包,要么屏蔽,这里取后者。

    shell 复制代码
    In file included from mosquitto_ctrl.c:19:0:
    ../../config.h:86:27: fatal error: cjson/cJSON.h: No such file or directory
     #  include <cjson/cJSON.h>
                               ^
    compilation terminated.
    make[5]: *** [mosquitto_ctrl.o] Error 1
    shell 复制代码
     # Applies to all...
     MAKE_FLAGS += WITH_DOCS=no
    +MAKE_FLAGS += WITH_CJSON=no
     ifeq ($(BUILD_VARIANT),nossl)
     	MAKE_FLAGS += WITH_TLS=no WITH_WEBSOCKETS=no
     else
     	MAKE_FLAGS += WITH_WEBSOCKETS=$(if $(CONFIG_MOSQUITTO_LWS),"yes","no")
     endif
  4. 提示缺少 pthread_、dlopen 等等相关接口未定义,没有指定链接库 lpthread、-ldl

    shell 复制代码
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `pthread_rwlock_destroy@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `pthread_setspecific@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `pthread_rwlock_init@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `pthread_key_create@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `dlopen@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `dlsym@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `dlclose@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `dladdr@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `pthread_rwlock_rdlock@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `dlerror@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `pthread_rwlock_unlock@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `pthread_getspecific@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `pthread_rwlock_wrlock@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `pthread_key_delete@GLIBC_2.17'
    out/r818-evb1/staging_dir/target/usr/lib/libcrypto.so: undefined reference to `pthread_once@GLIBC_2.17'
    shell 复制代码
     # Applies to all...
     MAKE_FLAGS += WITH_DOCS=no
     MAKE_FLAGS += WITH_CJSON=no
    +
    +MAKE_FLAGS += \
    +	FPIC="$(FPIC)" \
    +	CFLAGS="$(TARGET_CFLAGS)" \
    +	LDFLAGS="$(TARGET_LDFLAGS) -lpthread -ldl"
    +
     ifeq ($(BUILD_VARIANT),nossl)
     	MAKE_FLAGS += WITH_TLS=no WITH_WEBSOCKETS=no
     else
     	MAKE_FLAGS += WITH_WEBSOCKETS=$(if $(CONFIG_MOSQUITTO_LWS),"yes","no")
     endif
  5. 提示没有找到 mosquitto_passwd 文件,是因为新版本的源代码目录结构发生改变。

    shell 复制代码
    install: cannot stat 'out/r818-evb1/compile_dir/target/mosquitto-ssl/mosquitto-2.0.18/src/mosquitto_passwd': No such file or directory
    shell 复制代码
     # This installs files into ./staging_dir/. so that you can cross compile from the host
     define Build/InstallDev
     	$(INSTALL_DIR) $(1)/usr/include
    -	$(CP) $(PKG_BUILD_DIR)/lib/mosquitto.h $(1)/usr/include
    +	$(CP) $(PKG_BUILD_DIR)/include/mosquitto.h $(1)/usr/include
     	$(CP) $(PKG_BUILD_DIR)/lib/cpp/mosquittopp.h $(1)/usr/include
     	$(INSTALL_DIR) $(1)/usr/lib
  6. 提示没有找到 mosquitto.h 文件,是因为新版本的源代码目录结构发生改变。

    shell 复制代码
    cp: cannot stat 'out/r818-evb1/compile_dir/target/mosquitto-ssl/mosquitto-2.0.18/lib/mosquitto.h': No such file or directory
    shell 复制代码
     # This installs files into ./staging_dir/. so that you can cross compile from the host
     define Build/InstallDev
     	$(INSTALL_DIR) $(1)/usr/include
    -	$(CP) $(PKG_BUILD_DIR)/lib/mosquitto.h $(1)/usr/include
    +	$(CP) $(PKG_BUILD_DIR)/include/mosquitto.h $(1)/usr/include
     	$(CP) $(PKG_BUILD_DIR)/lib/cpp/mosquittopp.h $(1)/usr/include

完整补丁

shell 复制代码
--- package\network\mosquitto\Makefile	
+++ package\network\mosquitto\Makefile.bak	
@@ -6,20 +6,20 @@
 # See /LICENSE for more information.
 #
 
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=mosquitto
-PKG_VERSION:=1.4.8
+PKG_VERSION:=2.0.18
 PKG_RELEASE:=1
 PKG_LICENSE:=BSD-3-Clause
 PKG_LICENSE_FILES:=LICENSE.txt
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://mosquitto.org/files/source/
-PKG_MD5SUM:=d859cd474ffa61a6197bdabe007b9027
+PKG_MD5SUM:=7fe95d0bef1aacd291d21d7752fbd21b
 PKG_BUILD_DIR:=$(COMPILE_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
 
 include $(BUILD_DIR)/package.mk
 
 define Package/$(PKG_NAME)/default
   SECTION:=net
@@ -168,13 +168,13 @@
 endef
 
 define Package/mosquitto/install
 	$(call Package/mosquitto/install/default,$(1))
 ifeq ($(CONFIG_MOSQUITTO_PASSWD),y)
 	$(INSTALL_DIR) $(1)/usr/bin
-	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mosquitto_passwd $(1)/usr/bin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/apps/mosquitto_passwd/mosquitto_passwd $(1)/usr/bin
 endif
 endef
 
 define Package/mosquitto-client/install
 	$(INSTALL_DIR) $(1)/usr/bin
 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/client/mosquitto_pub $(1)/usr/bin/mosquitto_pub
@@ -182,13 +182,13 @@
 endef
 Package/mosquitto-client-nossl/install = $(Package/mosquitto-client/install)
 
 # This installs files into ./staging_dir/. so that you can cross compile from the host
 define Build/InstallDev
 	$(INSTALL_DIR) $(1)/usr/include
-	$(CP) $(PKG_BUILD_DIR)/lib/mosquitto.h $(1)/usr/include
+	$(CP) $(PKG_BUILD_DIR)/include/mosquitto.h $(1)/usr/include
 	$(CP) $(PKG_BUILD_DIR)/lib/cpp/mosquittopp.h $(1)/usr/include
 	$(INSTALL_DIR) $(1)/usr/lib
 	$(CP) $(PKG_BUILD_DIR)/lib/libmosquitto.so.1 $(1)/usr/lib/
 	$(CP) $(PKG_BUILD_DIR)/lib/cpp/libmosquittopp.so.1 $(1)/usr/lib/
 	$(LN) libmosquitto.so.1 $(1)/usr/lib/libmosquitto.so
 	$(LN) libmosquittopp.so.1 $(1)/usr/lib/libmosquittopp.so
@@ -207,12 +207,19 @@
 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/cpp/libmosquittopp.so.1 $(1)/usr/lib/
 	$(LN) libmosquittopp.so.1 $(1)/usr/lib/libmosquittopp.so
 endef
 
 # Applies to all...
 MAKE_FLAGS += WITH_DOCS=no
+MAKE_FLAGS += WITH_CJSON=no
+
+MAKE_FLAGS += \
+	FPIC="$(FPIC)" \
+	CFLAGS="$(TARGET_CFLAGS)" \
+	LDFLAGS="$(TARGET_LDFLAGS) -lpthread -ldl"
+
 ifeq ($(BUILD_VARIANT),nossl)
 	MAKE_FLAGS += WITH_TLS=no WITH_WEBSOCKETS=no
 else
 	MAKE_FLAGS += WITH_WEBSOCKETS=$(if $(CONFIG_MOSQUITTO_LWS),"yes","no")
 endif
相关推荐
Yawesh_best23 分钟前
思源笔记轻松连接本地Ollama大语言模型,开启AI写作新体验!
笔记·语言模型·ai写作
CXDNW2 小时前
【网络面试篇】HTTP(2)(笔记)——http、https、http1.1、http2.0
网络·笔记·http·面试·https·http2.0
使者大牙2 小时前
【大语言模型学习笔记】第一篇:LLM大规模语言模型介绍
笔记·学习·语言模型
ssf-yasuo2 小时前
SPIRE: Semantic Prompt-Driven Image Restoration 论文阅读笔记
论文阅读·笔记·prompt
ajsbxi2 小时前
苍穹外卖学习记录
java·笔记·后端·学习·nginx·spring·servlet
TeYiToKu3 小时前
笔记整理—linux驱动开发部分(9)framebuffer驱动框架
linux·c语言·arm开发·驱动开发·笔记·嵌入式硬件·arm
dsywws3 小时前
Linux学习笔记之时间日期和查找和解压缩指令
linux·笔记·学习
cuisidong19974 小时前
5G学习笔记三之物理层、数据链路层、RRC层协议
笔记·学习·5g
乌恩大侠4 小时前
5G周边知识笔记
笔记·5g
咔叽布吉6 小时前
【论文阅读笔记】CamoFormer: Masked Separable Attention for Camouflaged Object Detection
论文阅读·笔记·目标检测