cargo_emit

Macro rustc_link_lib

Source
macro_rules! rustc_link_lib {
    (to: $stream:expr, $name:expr $(,)?) => { ... };
    (to: $stream:expr, $name:expr => $kind:expr $(,)?) => { ... };
    (to: $stream:expr, $($name:expr $(=> $kind:expr)?),+ $(,)?) => { ... };
    ($name:expr $(,)?) => { ... };
    ($name:expr => $kind:expr $(,)?) => { ... };
    ($($name:expr $(=> $kind:expr)?),+ $(,)?) => { ... };
}
Expand description

Tells Cargo to pass $lib to the compiler as a -l flag.

This is equivalent to:

println!("cargo:rustc-link-lib=[$kind=]$name");

ยงExamples

Useful for telling the linker what libraries should be linked.

cargo_emit::rustc_link_lib!(
    "ssl", // same as `=> "dylib"`
    "ruby" => "static",
    "CoreFoundation" => "framework",
);

or, in case you want it to emit to a custom stream:

let mut stdout = std::io::stdout();
cargo_emit::rustc_link_lib!(
    to: stdout,
    "ssl", // same as `=> "dylib"`
    "ruby" => "static",
    "CoreFoundation" => "framework",
);