Skip to content

Commit

Permalink
Update c-with-rust.md
Browse files Browse the repository at this point in the history
modify the description about "build.rs"
  • Loading branch information
OccupyMars2025 authored May 7, 2023
1 parent 897fcf5 commit 1012eb0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/interoperability/c-with-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ In the simplest case of compiling a single C file as a dependency to a static li
```rust,ignore
fn main() {
cc::Build::new()
.file("foo.c")
.compile("libfoo.a");
.file("src/foo.c")
.compile("foo");
}
```

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 comments on commit 1012eb0

Please sign in to comment.