MOCKBA
September 19, 2024, 12:36am
1
Is there a way to make Rust executable portable between Linux versions? Currently I am getting:
./rb: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./rb)
I do not use any particular crate inside, just std . I just want that my program runs on any Linux, as for example java .
1 Like
You might be interested in alternative targets, like x86_64-unknown-linux-musl
.
https://doc.rust-lang.org/rustc/platform-support.html#tier-2-with-host-tools
8 Likes
MOCKBA
September 20, 2024, 11:58pm
3
Thanks. It looks like I am currently out of a luck, because I need to install musl-gcc and probably other components.
Vorpal
September 21, 2024, 9:15am
4
Huh? Those are just needed on the build host, the final program can be statically linked with musl.
I recommend using GitHub - rust-cross/cargo-zigbuild: Compile Cargo project with zig as linker for easy cross compilation (including to same architecture but different libc). If that doesn't work (if you have C dependencies it can be finicky) consider GitHub - cross-rs/cross: “Zero setup” cross compilation and “cross testing” of Rust crates
Both of these can also be used to target older glibc if you prefer to do that instead.
1 Like
MOCKBA
September 24, 2024, 12:35am
5
Thanks, it can be a solution. However I decided to provide a simple 3 steps building instruction including a setup of rustc. I tested the steps on Raspberry Pi and Windows Arm, and it seems worked. Thanks again.