Build mavlink-router as Static AArch64 musl Binary
mavlink-router forwards MAVLink packets between UART, UDP, and TCP endpoints.
It is useful on a companion computer or embedded Linux board when one MAVLink
source should be shared by several clients.
This guide builds mavlink-routerd as a static AArch64 Linux binary using the
musl cross compiler from musl.cc.
Read more on linux toolchain and cross compiler linux cross compiler toolchain
Step 1: install host tools
Install the tools used to download and build the source:
git: downloadmavlink-router.meson: configure the build.ninja: run the build.pkg-config: helper used by many C/C++ build systems.file: check the output binary type.wget: download the musl cross compiler archive.
Step 2: install aarch64 musl cross compiler
Download the prebuilt musl.cc toolchain:
Tip
The archive name is selected by the target CPU, not by the host CPU.
For an x86_64 Ubuntu host that builds for aarch64 Linux, use:
Add the compiler to your shell path:
Step 3: verify the compiler
Check that the C and C++ compilers are available:
These tools run on the host machine and create AArch64 Linux binaries linked against musl.
Step 4: download mavlink-router
From your workspace root:
The submodule step is required because mavlink-router uses the MAVLink C
library as a dependency.
Step 5: record the source revision
Record the exact source version used for the build:
git -C <path> ... means: run the Git command as if you first changed directory to
Example:
is equivalent to:
This makes the build easier to reproduce later.
Step 6: create the Meson cross file
Create the toolchain folder:
Create toolchains/aarch64-linux-musl.ini:
Important static build settings:
default_library = 'static': prefer static libraries.c_link_args = ['-static', '-no-pie']: statically link C code.cpp_link_args = ['-static', '-no-pie']: statically link C++ code.b_pie = false: avoid position-independent executable mode for this static build.
Step 7: configure with Meson
Remove any old build folder:
Configure the cross build:
What this command does:
build/mavlink-router-aarch64-musl-static: output build directory.external/mavlink-router: source directory.--cross-file: tells Meson which compiler and target machine to use.--buildtype release: optimized release build.--strip: strip symbols during install/build output where supported.-Dsystemdsystemunitdir=...: sets the systemd unit install path.
Step 8: build with Ninja
Build the project:
The main binary is:
Strip the final binary:
Step 9: verify the binary
Check that the output is an aarch64 executable:
Expected output should include:
Check the ELF header:
Check that there is no dynamic interpreter:
Expected interpreter check:
Step 10: test with QEMU
Install QEMU user emulation:
Run the help command:
The command should print the mavlink-routerd usage text.
Step 11: copy to Raspberry Pi
Copy the static binary to a Raspberry Pi target:
Check it on the Raspberry Pi:
If file is not installed on the Raspberry Pi, run only: