Apply suggestions from code review

pull/440/head
Yuki Okushi 2 weeks ago committed by GitHub
parent ed039e48fe
commit aad0fd9046
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -23,20 +23,23 @@ libc = "0.2.0"
## Prepare the build script ## Prepare the build script
Because [snappy](https://github.com/google/snappy) is a static library by default. So there is no C++ std linked in the output artifact. In order to use this foreign library in Rust, we have to manually specify that we want to link stdc++ in our project. The easiest way to do this is by setting up a build script. Because [snappy](https://github.com/google/snappy) is a static library by default.
So there is no C++ std linked in the output artifact.
n order to use this foreign library in Rust, we have to manually specify that we want to link stdc++ in our project.
The easiest way to do this is by setting up a build script.
First edit `Cargo.toml`, inside `package` add `build = "build.rs"`. First edit `Cargo.toml`, inside `package` add `build = "build.rs"`:
```toml ```toml
[package] [package]
... ...
build = "build.rs" build = "build.rs"
``` ```
Then create a new file at the root of your workspace, named `build.rs`. Then create a new file at the root of your workspace, named `build.rs`:
```rust ```rust
// build.rs // build.rs
fn main() { fn main() {
println!("cargo:rustc-link-lib=dylib=stdc++"); println!("cargo:rustc-link-lib=dylib=stdc++"); // This line may be unnecessary for some environment.
println!("cargo:rustc-link-search=<YOUR SNAPPY LIBRARY PATH>"); println!("cargo:rustc-link-search=<YOUR SNAPPY LIBRARY PATH>");
} }
``` ```

Loading…
Cancel
Save