已经配置好的环境
- ndk-built 有效,ndk 环境变量配置完毕,ndk arm64 配置完毕,cargo target aarch64 配置完毕
参照的有
https://blog.csdn.net/weixin_43939392/article/details/123123889
https://blog.csdn.net/cookic12346/article/details/124186671
https://blog.csdn.net/u011376563/article/details/123200461
https://blog.csdn.net/sinat_41915699/article/details/124694727
-
rustc 已经更新到 5-18 最新版本
-
cargo build --target aarch64-linux-android
后编译报错为
Compiling rust_android v0.1.0 (/home/XXX/Documents/Code/rust_android)
error: linking with /home/dji/Android/Sdk/ndk/23.0.7599858/arm64/bin/aarch64-linux-android-gcc
failed: exit status: 1
|
= note: "
= note: ld: error: unable to find library -lgcc clang120: error: linker command failed with exit code 1 (use -v to see invocation)
error: could not compile rust_android
due to previous error
- 尝试用官网
https://github.com/rust-lang/rust/pull/85806
方法,在 ndk 里的 libunwind.a 同目录下创建 libgcc.a 写入 INPUT(-lunwind),但是并没有用
评论区
写评论好吧,已经解决
到 ndk 里 find -name libunwind.a
看到一共有2处是 aarch64 下的
一个 toolchain 一个 arm64
都要按照官网的修改来操作
https://github.com/rust-lang/rust/pull/85806
亲测可一编出来 ARM aarch64 的 bin 文件了
.cargo/config 配置为
[build] target = "aarch64-linux-android" [target.aarch64-linux-android] ar = "/home/XXX/Android/Sdk/ndk/23.0.7599858/arm64/bin/aarch64-linux-android-ar" linker = "/home/XXX/Android/Sdk/ndk/23.0.7599858/arm64/bin/aarch64-linux-android-gcc"