Skip to content

Commit f27632c

Browse files
Merge #352
352: Update c-with-rust.md r=eldruin a=OccupyMars2025 modify the description about `build.rs` Co-authored-by: OccupyMars2025 <31559413+OccupyMars2025@users.noreply.github.com>
2 parents 897fcf5 + 69e3109 commit f27632c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/interoperability/c-with-rust.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ In the simplest case of compiling a single C file as a dependency to a static li
127127
```rust,ignore
128128
fn main() {
129129
cc::Build::new()
130-
.file("foo.c")
131-
.compile("libfoo.a");
130+
.file("src/foo.c")
131+
.compile("foo");
132132
}
133133
```
134+
135+
The `build.rs` is placed at the root of the package. Then `cargo build` will compile and execute it before the build of the package. A static archive named `libfoo.a` is generated and placed in the `target` directory.

0 commit comments

Comments
 (0)