cargo/rust 交叉构建工具,无需 wsl/docker/colima,可在 windows 上原生运行

1 月 13 日
 zijiren

大家好,我构建了一套交叉编译工具链,支持在 Windows 、macOS 或 Linux 上为其他平台构建二进制文件,且无需 WSL 、Docker 或 Colima 。

例如,你可以在 Windows 机器上构建可在 Linux 上运行的可执行程序。

用法很简单:

cargo install cargo-cross
cargo cross build --target x86_64-unknown-linux-musl
cargo cross build --target x86_64-unknown-linux-glibc --glibc-version 2.42
cargo cross build --target x86_64-pc-windows-gnu

支持:

windows 构建到 windows/linux/freebsd/android

linux 构建到 windows/linux/macos/ios/freebsd/android

macos 构建到 windows/linux/macos/ios/freebsd/android

你还可以选择使用的是 glibc 还是 musl libc ,甚至可以选择 glibc 版本(支持 2.28-2.42 )

项目地址: https://github.com/zijiren233/cargo-cross

求 star

2800 次点击
所在节点    程序员
23 条回复
zijiren
1 月 14 日
@chengYT zigbuild 不支持 musl
chengYT
1 月 15 日
@ljkgpxs 我这里甚至还有 2.12 版本的老系统需要支持
d0r1an
1 月 15 日
@pursuer 可以用这个起一个沙箱,然后在里面编译

https://github.com/boxlite-ai/boxlite

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://v2ex.ih06.com/t/1185353

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX