5

I am compiling my Rust code to be used as a CLI.

I want it installable on the widest possible range of x86_64-unknown-linux-gnu based systems, particularly Ubuntu's.

I am using a docker base image FROM rust:latest for builds, but this compile-host has glibc v2.29.

When I try to run the binary on another Debian system with (Debian GLIBC 2.28-10) 2.28 it exits with an error:

clix: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by clix)

So does this mean I need to compile on an old Ubuntu (ubuntu:16.04) to support Ubuntu 16 and newer?

Is there a an alternative where I can compile on rust:latest and have my binary work on old Ubuntu OS's?

Related:

7
  • if you want to compile your image to run on ubuntu 16 base yes you should take an ubuntu 16 base, just do a rustup install in the image. In docker host is not important so I don't follow you Commented Sep 23, 2021 at 5:40
  • 1
    @Stargateur My understanding is that Docker is only used for the build, possibly in CI. The resulting binary is supposed to run on the host system directly. Commented Sep 23, 2021 at 8:41
  • @stargateur The docker container is just for compiling. The compiled binary is to distribute as a release download (which is why I want it to work for many systems). I was under the impression Rust compiled static binaries that just work in most Linux distributions, but actually you have to be careful about the release date of the OS you compile on. Commented Sep 23, 2021 at 8:52
  • ecen if rust is by default static there always by the loader that need to be load i don t know one elf program that can be share like that. since every distribution have its own path and specificity it s not possible Commented Sep 23, 2021 at 8:58
  • 2
    @Stargateur Rust binaries are mostly statically linked by default, but the *-linux-gnu targets link against glibc dynamically (and other external libs, e.g. OpenSSL), so you end up with a dynamically linked ELF binary, not a statically linked one. Commented Sep 23, 2021 at 14:35

1 Answer 1

0

So does this mean I need to compile on an old Ubuntu (ubuntu:16.04) to support Ubuntu 16 and newer?

This is the simplest solution.

Is there a an alternative where I can compile on rust:latest and have my binary work on old Ubuntu OS's?

Yes: you can build yourself a Linux-to-older-Linux cross-compiler, and use it to build your binary on rust:latest. This isn't entirely trivial thing to do, and usually "build on older" is the more straightforward solution.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.