fix: link libc++ statically — crash on launch due to missing libc++_shared.so

The app crashed immediately when loading libwzp_android.so because the
cc crate's default dynamic linking produced a runtime dependency on
libc++_shared.so, which was never packaged into the APK.

Adding .cpp_link_stdlib(Some("c++_static")) to build.rs bakes the C++
runtime into libwzp_android.so directly, eliminating the missing .so.

See issues/001-libc++-shared-crash.md for full diagnosis and logcat trace.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-04-05 08:52:55 +04:00
parent 8d5f6fe044
commit e751af7e38
2 changed files with 91 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ fn main() {
cc::Build::new()
.cpp(true)
.std("c++17")
.cpp_link_stdlib(Some("c++_static"))
.file("cpp/oboe_bridge.cpp")
.include("cpp")
.include(oboe_path.join("include"))
@@ -24,6 +25,7 @@ fn main() {
cc::Build::new()
.cpp(true)
.std("c++17")
.cpp_link_stdlib(Some("c++_static"))
.file("cpp/oboe_stub.cpp")
.include("cpp")
.compile("oboe_bridge");