Skip to content

Instantly share code, notes, and snippets.

@lupyuen
Last active June 2, 2023 01:28
Show Gist options
  • Save lupyuen/39237910b14afb316774fbfbd4c9b9c8 to your computer and use it in GitHub Desktop.
Save lupyuen/39237910b14afb316774fbfbd4c9b9c8 to your computer and use it in GitHub Desktop.
Install Zig in Termux Android

Install Zig in Termux Android

Here are the steps to install Zig Compiler in Termux Android...

Install Termux from F-Droid, because the Google Play version is outdated...

Launch Termux on Android and enter...

pkg upgrade
pkg update

In Termux Android, download Zig Compiler for Linux AArch64...

(Might be easier over SSH)

## Download Zig Compiler
curl -O -L https://ziglang.org/builds/zig-linux-aarch64-0.11.0-dev.3333+32e719e07.tar.xz
tar xf zig-linux-aarch64-0.11.0-dev.3333+32e719e07.tar.xz
zig-linux-aarch64-0.11.0-dev.3333+32e719e07/zig version

## Add Zig Compiler to PATH
nano ~/.bashrc
## Add this line, then save and exit:
export PATH="$PATH:$HOME/zig-linux-aarch64-0.11.0-dev.3333+32e719e07"

## Update PATH
. ~/.bashrc

## Create Zig App
mkdir hello-world
cd hello-world
zig init-exe

## Build and run the Zig App
zig build run
zig-out/bin/hello-world

Ignore the warnings...

$ zig build run
zig build-exe hello-world Debug native: error:
warning: Encountered error: FileNotFound, falling back to default ABI and dynamic linker.

All your codebase are belong to us.
Run `zig build test` to run the tests.

(More about FileNotFound)

(Fix for FileNotFound)

Up Next: Create a Zig App with Termux GUI

TODO: Run an LVGL Graphical App with Termux GUI and Zig Compiler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment