Skip to content

Latest commit

 

History

History
40 lines (24 loc) · 1.01 KB

static-linking.md

File metadata and controls

40 lines (24 loc) · 1.01 KB

Static Linking

Linux

Install musl

musl is needed to enable static linking.

You can use the following instructions to install musl on Debian:

apt install musl-tools

Install rustc target

Then you need to install the corresponding musl rust target (see rustc --print target-list | grep musl):

rustup target add x86_64-unknown-linux-musl

Compile

Then compile with the features that do not require dynamic linking:

cargo build --target=x86_64-unknown-linux-musl --no-default-features --features vendored-openssl,vendored-c-ares

Windows

Windows provides both dynamic and static C runtimes.

See C runtime (CRT) and C++ standard library (STL) .lib files.

You can change to use a static runtime by setting -C target-feature=+crt-static rustc flag.

See Static and dynamic C runtimes.