Does Rust compile required C libraries in to the executable?


Hey. I want to use the crate OpenSSL.
On their crate site, they notice that OpenSSL needs to be present on the system to build the project.
My question is now, gets OpenSSL compiled in to my project or do I need to install OpenSSL on the system where I want to run my program?



By default, and in general, no. You have to tell Cargo what to link - typically by printing out some special directives as part of a build script.

In the case of OpenSSL, its build script checks a few things before deciding between static and dynamic linking. If you set the environment variable OPENSSL_STATIC to anything other than 0, it’ll force it to statically link. The relevant logic for this is here. In this case, you’ll need to have OpenSSL static libs available on your build machine, but not on the machine where you run it.