Skip to content

Commit a865156

Browse files
committed
Explain linking for upstream crates (based on #12575)
1 parent 2d2ff6f commit a865156

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/doc/trpl/advanced-linking.md

+17
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@ but supporting the range of linking possibilities made available by other
55
languages is important for Rust to achieve seamless interaction with native
66
libraries.
77

8+
# Native libraries required by upstream crates
9+
10+
Sometimes an upstream Rust crate won't include an appropriate `#[link(...)]`
11+
attribute to automatically link against a required natve library on your system.
12+
This can happen if libraries are named differently across platforms (so only
13+
you as the crate consumer know the actual name). To link against the appropriate
14+
library for your system, you can use the `#[link(...)]` attribute on an empty
15+
extern block:
16+
17+
``` no_run
18+
extern crate foo;
19+
20+
#[link(name = "foonative3"]
21+
extern {}
22+
# fn main() {}
23+
```
24+
825
# Link args
926

1027
There is one other way to tell rustc how to customize linking, and that is via

0 commit comments

Comments
 (0)