codex - 💡(How to fix) Fix Android/Termux build fails: oboe-sys requires -lc++_static due to incorrect cfg condition in tui/Cargo.toml

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

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.

Fix Action

Fix / Workaround

Workaround (used in current Termux builds)

Code Example

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

---

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

---

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

---

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

---

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

---

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

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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING