You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/interoperability/c-with-rust.md
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -127,7 +127,9 @@ In the simplest case of compiling a single C file as a dependency to a static li
127
127
```rust,ignore
128
128
fn main() {
129
129
cc::Build::new()
130
-
.file("foo.c")
131
-
.compile("libfoo.a");
130
+
.file("src/foo.c")
131
+
.compile("foo");
132
132
}
133
133
```
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