What is the correct way to include precompiled static library within crate

Hello !

Pretty much everything is in the title.
I have a precompiled static library I need to deliver with the crate for linking. (I don't have the source, only .a/.lib + .dll/.so )
What is the recommended way to include a precompiled static library used during linking with a crate?

Thank you.

1 Like

Make build.rs script that outputs link instructions for Cargo.

cargo:rustc-link-lib=static=foo
cargo:rustc-link-search=native=/path/to/foo

https://doc.rust-lang.org/cargo/reference/build-scripts.html

You can also put it in a separate sys crate to make it reusable.

1 Like

Thank you!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.