【发布时间】:2021-10-22 16:20:15
【问题描述】:
我正在尝试让 rust 在 android 上运行。但是,当我尝试交叉编译到 android 时,出现以下链接错误:
$ cargo build --target=arm-linux-androideabi
Compiling <project> v0.1.0 (<project>)
error: linking with `/opt/android-sdk/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi31-clang` failed: exit status: 1
(very long toolchain command from cargo)
ld: error: unable to find library -lgcc
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
我已经安装了ndk并将.cargo/config中的链接器更改为android clang链接器。我还尝试了具有相同结果的独立工具链。我使用的指南如下:https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-21-rust-on-android.html
使用crate-type = ["rlib"] 而不是crate-type = ["cdylib"] 时交叉编译确实有效,但我需要.so 文件而不是.rlib 文件。
如果相关,我正在使用 Manjaro Linux。
【问题讨论】:
标签: linux rust android-ndk rust-cargo