I was wondering about statically compiling FFI libraries into a rust binary. I read through The (old) Rust Foreign Function Interface Guide and saw an answer on How to I tell Rust where to look for a static library? - Stack Overflow. While that SO answer worked, it gave me a deprecation warning:
warning: an arbitrary build command has now been deprecated. It has been replaced by custom build scripts. For more information, see Page Moved
So I just wanted to verify that this is the proper way to set up statically statically compiled libraries with cargo. Re-using the snappy example:
# in Cargo.toml
build = "build.rs"
# in build.rs
fn main() {
println!("cargo:rustc-flags= -L /usr/local/lib")
}
# in main.rs
#[link(name = "snappy", kind = "static")]
I put together a complete buildable example on github. But I wanted to ask if this the proper way to do it before I commented or posted a new answer to the existing SO thread.
Thanks for your help!