I am trying to build a library for Android in Rust. The library is not loadable by JNI, which fails with:
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "rust_begin_unwind" referenced by "/data/app/<name-of-app>/lib/x86/lib<name-of-lib>.so"...
The build/link command is:
cargo rustc --target=i686-linux-android -- -C linker=tmp/ndk.x86/bin/i686-linux-android-gcc
tmp/ndk.x86 is a so-called “standalone build” of the NDK.
The error seems to be saying that the library is missing some symbols related to Rust exception handling. It stands to reason that everything from Rust these should be statically linked; but it’s not clear how to accomplish this (what options to pass, &c).
There are some templates online and I am just about to the point of using them; but it would be nice to understand what is going wrong here.