当 rustc 启用了 musl 时,无法使用 cargo 构建 rust-libc
failure to build rust-libc using cargo when rustc is musl-enabled
我按照 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?'
这对我构建 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\" --emit=dep-info,link
我按照 this link
成功创建了musl
配置 rustc
当我使用 cargo rustc -- --target=x86_64-unknown-linux-musl
'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?'
这对我构建 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\" --emit=dep-info,link