Android/Termux build fails: oboe-sys requires -lc++_static due to incorrect cfg condition in tui/Cargo.toml

Open 💬 2 comments Opened May 26, 2026 by bash0816

Environment

  • Platform: Android (Termux) — aarch64
  • Rust target: aarch64-linux-android (native build on-device)
  • codex-rs version: 0.133.0

Error

error: linking with `clang` failed: exit status: 1
  = note: ld.lld: error: unable to find library -lc++_static

Root Cause

tui/Cargo.toml conditionally includes cpal as follows:

[target.'cfg(not(target_os = "linux"))'.dependencies]
cpal = "0.15"

On Android, Rust's target_os is "android" (not "linux"), so this condition evaluates to true and cpal gets pulled in. cpaloboeoboe-sys, and oboe-sys emits cargo:rustc-link-lib=static=c++_static for Android targets.

However, Termux does not provide libc++_static.a — only libc++_shared.so is available. The Android NDK static C++ runtime is not shipped with Termux.

Suggested Fix

Exclude Android from the cpal dependency, since audio is not needed for a CLI tool on Termux:

[target.'cfg(not(any(target_os = "linux", target_os = "android")))'.dependencies]
cpal = "0.15"

Alternatively, enable the oboe-shared-stdcxx feature on cpal for Android to use libc++_shared instead:

[target.'cfg(target_os = "android")'.dependencies]
cpal = { version = "0.15", features = ["oboe-shared-stdcxx"] }

Note: cpal exposes an oboe-shared-stdcxx feature that propagates shared-stdcxx to oboe-sys, switching the link from c++_static to c++_shared.

Workaround (used in current Termux builds)

Create a linker script shim:

mkdir -p ~/lib_shim
printf 'INPUT(-lc++_shared)\n' > ~/lib_shim/libc++_static.a

Add to RUSTFLAGS:

-C link-arg=-L/path/to/lib_shim -C link-arg=-L/usr/lib

Additional Context

This was discovered while building codex-rs natively on Android/Termux for @bash0816/codex-termux, a community Termux wrapper for Codex.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗