[SOLVED] #[link(name, kind)] supply name,kind as cargo parameters?


#1

I’m just finishing up a small program and got stuck with the build process.

The crate is supposed to compile on Linux and OSX, but the 3rd party lib that I link to is called differently on those platforms. A request to use a common name was denied, because cmake can handle that easily for the C++ codebase.

I tried to find a way to pass the library name to Cargo, also via a build script, but without success so far.
Is there a way to tell Cargo the (name,kind) for the #[link] directives?


#2

From a build script you can println!("cargo:...") to replicate the behavior of #[link] directives. Here is the documentation.

HTH


#3

Thank you very much.
It took me a while to realize that I don’t have to put any #[link] directive into the source code.