【问题标题】:Cross-compilation to x86_64-unknown-linux-gnu fails on Mac OSX在 Mac OSX 上交叉编译到 x86_64-unknown-linux-gnu 失败
【发布时间】:2017-03-18 09:08:28
【问题描述】:

我尝试将我的一个 Rust 项目编译到 x86_64-unknown-linux-gnu 目标:

$ cargo build --target=x86_64-unknown-linux-gnu
 Compiling deployer v0.1.0 (file:///Users/raphael/web/deployer)
  error: linking with `cc` failed: exit code: 1
  |
  = note: "cc"
  = note: clang: warning: argument unused during compilation: '-pie'
ld: unknown option: --as-needed
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我不知道如何处理这样的消息。我应该怎么做才能让它发挥作用?

这是我的Cargo.toml 文件:

[package]
name = "deployer"
version = "0.1.0"
authors = ["..."]

[dependencies]
clap = "2.14.0"
time = "0.1.35"
slack-hook = "0.2"

货运版:

cargo 0.13.0-nightly (109cb7c 2016-08-19)

锈版本:

rustc 1.12.0 (3191fbae9 2016-09-23)

我尝试使用 rustup 更新所有内容,但仍然遇到同样的问题。

【问题讨论】:

标签: linux macos rust cross-compiling rust-cargo


【解决方案1】:

cross-compile-rust-from-mac-to-linux 的启发,我通常安装这些依赖项以将 rust 从 Mac OS 交叉编译到 Linux(例如,用于 Docker 容器):

rustup target add x86_64-unknown-linux-gnu

# Install a pre-built cross compiler
brew tap SergioBenitez/osxct
brew install x86_64-unknown-linux-gnu

最后我可以在 Mac OS 上交叉编译到 Linux:

CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-unknown-linux-gnu-gcc \
cargo build --target=x86_64-unknown-linux-gnu

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-06
    • 1970-01-01
    • 2021-04-11
    • 2018-12-07
    • 1970-01-01
    • 2017-11-07
    • 1970-01-01
    • 2012-07-11
    相关资源
    最近更新 更多