【问题标题】:How to exclude a particular crate-type from build?如何从构建中排除特定的板条箱类型?
【发布时间】: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`.

如果我从hyperCargo.toml 中删除以下行

[lib]
crate-type = ["lib", "staticlib", "cdylib"]

然后我可以毫无问题地构建我的项目。

如何在不修改hyperCargo.toml 的情况下构建我的项目?如何从构建中排除其 staticlibcdylib 板条箱类型?

解决方案/解决方法

我为我的问题找到了解决方案/解决方法。我已经添加到.cargo/config

[target.aarch64-linux-android]
linker = 'aarch64-linux-android28-clang.cmd'

现在hyper 编译为libstaticlibcdylib。顺便说一句,想要cc 的是cdylib crate 类型。

【问题讨论】:

标签: android rust rust-cargo hyper reqwest


【解决方案1】:

解决方案/解决方法

我为我的问题找到了解决方案/解决方法。我已经添加到.cargo/config

[target.aarch64-linux-android]
linker = 'aarch64-linux-android28-clang.cmd'

现在hyper 编译为libstaticlibcdylib。顺便说一句,想要cc 的是cdylib crate 类型。

【讨论】:

    猜你喜欢
    • 2023-03-09
    • 2012-07-19
    • 2019-02-04
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 2023-02-14
    • 1970-01-01
    相关资源
    最近更新 更多