Skip to content

Commit 69e3109

Browse files
Merge pull request #1 from OccupyMars2025/modify-description-about-build.rs
Update c-with-rust.md
2 parents 897fcf5 + 1012eb0 commit 69e3109

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)