ARM platform cross compilation | MQTT-mosquitto

Publisher:BlossomWhisperLatest update time:2022-07-11 Source: csdn Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

There are two ways to compile mosquitto: cmake and make. Windows and Mac platforms use cmake compilation, and other platforms, including Linux platforms, use make to compile directly. Compiling mosquitto under Windows 7 details the steps to compile mosquitto under Windows 7.


This article introduces the compilation steps of mosquitto for a certain ARM platform.


Compiler Environment

Host: Ubuntu 16.04

Host: ARM, Cortex-A55

Cross compiler: aarch64-linux-gnu-gcc, 7.2.1 20171011 (Linaro GCC 7.2-2017.11)

Compilation steps

Download the latest mosquitto source code package from the official website of mosquitto. The host machine for this compilation is Ubuntu system, and the makefile provided by mosquitto is used directly for compilation. The compilation environment depends on the following:


cJSON: Enabled by default so that the client can output content in cJSON format. Disable the dependency by making WITH_CJSON=no.

openssl: provides ssl support for mosquitto, enabled by default, and disabled by making WITH_TLS=no;

pthreads: provides multi-thread support for mosquitto. Since the compilation environment is Linux system, the pthreads API environment is supported by default.

Prepare

OpenSSL

For the cross-compilation steps of openssl, please refer to Cross-compile OpenSSL.


cJSON

Download the latest cJSON source code and unzip it.

mkdir build

cmake -DCMAKE_INSTALL_PREFIX=/path/to/install -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++

make

make install

Compile

Unzip the mosquitto source package and execute the following command to compile:


make CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ CFLAGS="-I /path/to/openssl/install/include -I /path/to/cJson/install/include" LDFLAGS="-L /path/to/openssl/install/lib64 -L /path/to/cJson/install/lib -lssl -lcrypto -lcjson"


CC and CXX are used to specify the gcc and g++ compilers for the target platform;

CFLAGS: used to specify the installation directory of openssl and cjson header files;

LDFLAGS: used to specify the installation directory of openssl and cjson dynamic libraries;

After the compilation is complete, execute make install to install.


test

Copy cJSON, openssl, and mosquitto dynamic libraries to the target system;

Set LD_LIBRARY_PATH to specify the installation location of the above three types of dynamic libraries on the target system;

Copy the mosquitto_ctrl mosquitto_passwd mosquitto_pub mosquitto_rr mosquitto_sub test tools to the target system;

Here we take mosquitto_sub as an example to test the mosquitto subscription function. The example is as follows:

mosquitto_sub -h host_addr -p port -u username -P passwd -t the_topic_sub

1

-h: specifies the server address of mqtt broker;

-p: specifies the server port number of the mqtt broker;

-u: specifies the server login username of mqtt broker;

-P: specifies the server login password of mqtt broker;

-t: Specifies the topic to be subscribed locally.

Reference address:ARM platform cross compilation | MQTT-mosquitto

Previous article:at91sam9260 OpenWRT u-boot transplant
Next article:ARM platform cross compilation | OpenSSL

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号