#[link] attribute should better describe platform specific handling #638
Labels
E-Easy
We believe this would not be difficult to actually fix
New Content
Missing features or aspects of language not currently documented.
Uh oh!
There was an error while loading. Please reload this page.
When working cross platform, in particular when producing a dylib from Rust and then again consuming it, the current resolution of
#[link(name = "mylib"]
is somewhat confusing.If you start developing on Windows, Rust will produce a
mylib.dll
andmylib.dll.lib
. To use this lib again from Rust you will have to specify#[link(name = "mylib.dll")]
, thus giving the impression that the full file name has to be specified. On Mac, however,#[link(name = "libmylib.dylib"]
will fail (likewise Linux).If you start developing on Mac and Linux,
#[link(name = "mylib")]
just works, giving you the impression Rust handles the name resolution (fully) automatically like other platforms that just require the base name.In fact, the correct way to cross platform link against a dylib produced by Rust seems to be:
Since according to this issue the current behavior can't be fixed and is "stable", I believe this should be documented somewhere. For me, the
#[link]
attribute was where I started my debug journey originally.The documentation could be something like:
Update - Changed
#[cfg_attr]
to be more correctish ...The text was updated successfully, but these errors were encountered: