No link errors when building as executable main.rs rather than lib.rs
Error: linking with C:/Users/nafan/AppData/Local/ndk/26.2.11394342/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android34-clang++.cmd failed: exit code: 255
note: --version-script=C:\Users\nafan\AppData\Local\Temp\rustcfcjtoe\list"" was unexpected at this time.
config.toml
[target.aarch64-linux-android]
ar = "C:/Users/nafan/AppData/Local/ndk/26.2.11394342/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android34-clang++"
linker = "C:/Users/nafan/AppData/Local/ndk/26.2.11394342/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android34-clang++.cmd"
Cargo.toml
[lib]
name = "renderer"
crate-type = ["cdylib"]
[dependencies]
jni = "0.21.1"
lib.rs
use jni::{objects::JClass, sys::jint, JNIEnv};
#[no_mangle]
pub extern "C" fn Java_com_example_myapp_RustInterface_rustFunction(_env: JNIEnv, _class: JClass) -> jint {
let value = 42; // Example value
// Convert the value to JNI jint and return it
value as jint
}
Possible workaround is to change aarch64-linux-android34-clang++.cmd content a little bit
https://github.com/android/ndk/issues/1856#issuecomment-1542248775