Making a rust all-in-one package program


What are the steps of packaging a all-sufficient rust binary? I mean, I want to make a release where users may just download already compiled rust executable with all the libraries with it. For example:

$ ls release-0.6.2/

So the end-user needs to download the archive only, unpack it and he is able to use it without installing openssl into his system. So, the rust-executable loads these listed and at runtime instead of LD_LIBRARY_PATH ones… I thought of providing a shell script which does LD_PRELOAD and some other stuff. But I think I want to invent a bycycle here because it is common thing to do and there are best practices already I think.


It may be more straightforward to statically link to libssl and libcrypto so you don’t have to worry about tracking down dynamic libraries.


How can I do that with cargo ?


Make sure you have static libraries available (they end in .a), and set the environment variable OPENSSL_STATIC to 1 when building.


Probably that will solve this for openssl libraries but what about everything else?


Check out this post about rustup:

[…] it’s possible to distribute ELF binaries with no dynamic library dependencies that will run on any version of Linux.

If my understanding is correct, this is what you are looking for and rustup provides a very convenient way to achieve it.