Is this the proper way to specify statically compiled FFI libraries?


#1

I was wondering about statically compiling FFI libraries into a rust binary. I read through http://doc.rust-lang.org/guide-ffi.html and saw an answer on http://stackoverflow.com/a/26254062/410759. 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 http://doc.crates.io/build-script.html

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!