当rustc启用musc时,未能使用货物建立rust-libc

时间:2015-08-06 09:16:05

标签: rust rust-cargo musl

我已按照this link

成功创建了musl已配置的rustc

当我使用cargo rustc -- --target=x86_64-unknown-linux-musl

时,我尝试构建一个项目(使用非musl配置的rust构建得很好)失败了
 'error: could not find crate `libc` with expected target triple x86_64-unknown-linux-musl'

然后,我尝试使用crate中的代码创建rust-libc库。为了更准确,我使用cargo提供的命令来构建rust-libc,我只在命令中添加了--target=x86_64-unknown-linux-musl。这次报告失败了:

'error: could not find native static library `c`, perhaps an -L flag is missing?`'

我有两个问题:

  • 是否必须构建musl已配置cargo才能使用cargo build --target=x86_64-unknown-linux-musl

  • 我该如何解决这个问题:

    'error: could not find native static library `c`, perhaps an -L flag is missing?'
    

1 个答案:

答案 0 :(得分:3)

这对我来说构建了libc:

  

rustc --target = x86_64-unknown-linux-musl /address-of-libc/lib.rs --crate-name libc --crate-type lib -L ​​/ address-of-musldist / musldist / lib / --out-dir = / your-chosen-address / target --cfg feature = \“default \” - cfg feature = \“cargo-build \” - event = dep-info,link