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.
Previous article:at91sam9260 OpenWRT u-boot transplant
Next article:ARM platform cross compilation | OpenSSL
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Mfgtools tool to burn the image separately - Xunwei IMX6 development board device tree Android 6.0.1 system
- Teach you step by step how to design CPLD/FPGA and MCU together
- In three minutes, you can understand the concept and classification of power amplifiers!
- Gate circuits: AND gate, OR gate, NOT gate circuits and examples
- 4 types of electrical energy conversion, let’s take a look
- Summary of the differences between SPMSM and IPMSM
- DSP system design - Why is the DSP with large on-chip RAM more efficient?
- What are the advantages and disadvantages of BMS controlling the positive end of the battery and controlling the negative end?
- A brief summary of the DQ axis in the FOC algorithm
- 【NUCLEO-WL55JC2 Review】——by nich20xx