Skip to content

fix: link libm in Android shim build to resolve missing math symbols #54

Merged
SineVector241 merged 1 commit intoAvionBlock:masterfrom
towneh:master
Apr 11, 2026
Merged

fix: link libm in Android shim build to resolve missing math symbols #54
SineVector241 merged 1 commit intoAvionBlock:masterfrom
towneh:master

Conversation

@towneh
Copy link
Copy Markdown
Contributor

@towneh towneh commented Apr 11, 2026

Summary

The Android libopus.so is currently produced without -lm, so math functions used by CELT/SILK (sqrt, log, exp, etc.) end up as unresolved symbols. On Android,
libm is a separate shared object, and bionic reports the resulting load failure as a generic library "opus" not found error.

In Unity IL2CPP this manifests as a DllNotFoundException the moment OpusEncoder / OpusDecoder is constructed on arm64 devices — reproduced on a Pixel 8 Pro, but it
affects all Android arches produced by this workflow. The file is present in the APK and in the device's nativeLibraryDir, the ELF is arm64 and 16 KB-page aligned,
SONAME is clean — but readelf -d shows only DT_NEEDED: libdl.so, libc.so with no libm.so, which is the smoking gun.

The Linux shim step already passes -lm; the Android step was simply missing it.

Changes

  • Add -lm to the Android "Build with shim" link step, matching the Linux step.
  • Add -Wl,--no-undefined so any future missing dependency fails the GitHub Actions build loudly instead of silently producing a broken .so that only fails at dlopen
    time on-device.

The Android libopus.so was produced without -lm, so math functions used by
CELT/SILK (sqrt, log, exp, etc.) ended up as unresolved symbols. On Android,
libm is a separate shared object and bionic reports the resulting load
failure as a generic 'library not found' error, which manifested in Unity
IL2CPP as DllNotFoundException when initializing OpusEncoder/OpusDecoder on
arm64 devices (e.g. Pixel 8 Pro).

Add -lm to the Android shim link step (matching the Linux step) and
-Wl,--no-undefined so any future missing dependency fails the build instead
of silently producing a broken .so.
Copy link
Copy Markdown
Member

@SineVector241 SineVector241 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gyood

@SineVector241 SineVector241 merged commit c5f3f17 into AvionBlock:master Apr 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants