Table of Contents

DESCRIPTION

Use zig to easily cross-compile C programs for other architectures.

COMMANDS

Install

Install zig using asdf.

Compile

arm

CC="zig cc -target arm-linux-musleabi -static" make clean all

aarch64

CC="zig cc -target aarch64-linux-musl -static" make clean all

x864_64

CC="zig cc -target x86_64-linux-musl -static" make clean all

EXAMPLES

$ git clone https://github.com/msantos/runcron.git
$ cd runcron
$ CC="zig cc -target arm-linux-musleabi -static" make clean all

The compiled binary:

$ ldd runcron
not a dynamic executable
$ file runcron
runcron: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, with debug_info, not stripped
$ uname -m # host arch
x86_64

(markdown)