Aby uniknąć błędów GLIBC, możesz skompilować własną wersję Rust przeciwko statycznej alternatywnej bibliotece libc, musl.
Pobierz najnowszą stabilną wersją MUSL i zbudować go z opcją --disable-shared
:
$ mkdir musldist
$ PREFIX=$(pwd)/musldist
$ ./configure --disable-shared --prefix=$PREFIX
następnie zbudować Rust przeciwko MUSL:
$ ./configure --target=x86_64-unknown-linux-musl --musl-root=$PREFIX --prefix=$PREFIX
następnie zbudować projekt
$ echo 'fn main() { println!("Hello, world!"); }' > main.rs
$ rustc --target=x86_64-unknown-linux-musl main.rs
$ ldd main
not a dynamic executable
Dla Więcej informacji na ten temat można znaleźć w sekcji dokumentacji: advanced linking.
Jak podano w oryginalnej dokumentacji:
Jednakże, być może trzeba przekompilować natywnych bibliotek przeciwko MUSL zanim będą mogły być połączone przeciw.
Można również użyć rustup.
Usuń rdza zainstalowany przez rustup.sh
$ sudo /usr/local/lib/rustlib/uninstall.sh # only if you have
$ rm $HOME/.rustup
Install rustup
$ curl https://sh.rustup.rs -sSf | sh
$ rustup default nightly #just for ubuntu 14.04 (stable Rust 1.11.0 has linking issue)
$ rustup target add x86_64-unknown-linux-musl
$ export PATH=$HOME/.cargo/bin:$PATH
$ cargo new --bin hello && cd hello
$ cargo run --target=x86_64-unknown-linux-musl
$ ldd target/x86_64-unknown-linux-musl/debug/hello
not a dynamic executable
Pytasz o "Portable" binariów, ale tylko lista jeden system (Ubuntu) bez informacji o wersji. Czy w grę wchodzi wiele systemów? Jeśli tak, to jakie są dystrybucje i ich wersje? – Shepmaster