【发布时间】:2021-03-25 05:01:58
【问题描述】:
我的 Rust 项目依赖于 crate reqwest,它依赖于 hyper。
当我为 Android 平台构建项目时
cargo.exe build --target aarch64-linux-android
cargo 找不到cc。
Compiling hyper v0.14.4
error: linker `cc` not found
= note: The system cannot find the file specified. (os error 2)
error: aborting due to previous error
error: could not compile `hyper`.
如果我从hyper 的Cargo.toml 中删除以下行
[lib]
crate-type = ["lib", "staticlib", "cdylib"]
然后我可以毫无问题地构建我的项目。
如何在不修改hyper 的Cargo.toml 的情况下构建我的项目?如何从构建中排除其 staticlib 和 cdylib 板条箱类型?
解决方案/解决方法
我为我的问题找到了解决方案/解决方法。我已经添加到.cargo/config:
[target.aarch64-linux-android]
linker = 'aarch64-linux-android28-clang.cmd'
现在hyper 编译为lib、staticlib 和cdylib。顺便说一句,想要cc 的是cdylib crate 类型。
【问题讨论】:
标签: android rust rust-cargo hyper reqwest