Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cc::Build::new()
- .file("src/foo.c")
- .shared_flag(true)
- .compile("libfoo.so");
- # specially recognized by Cargo
- cargo:rustc-link-lib=static=foo
- cargo:rustc-link-search=native=/path/to/foo
- cargo:rustc-cfg=foo
- cargo:rustc-env=FOO=bar
- # arbitrary user-defined metadata
- cargo:root=/path/to/foo
- cargo:libdir=/path/to/foo/lib
- cargo:include=/path/to/foo/include
- .
- ├── Cargo.toml
- ├── build.rs
- └── src
- └── main.rs
- [package]
- # ...
- build = "build.rs"
- fn main() {
- println!("cargo:rustc-link-search=native=/usr/lib");
- println!("cargo:rustc-link-lib=static=foo");
- }
- use std::env;
- use std::fs;
- use std::path::Path;
- fn main() {
- // Get the output path
- let out_dir = env::var("OUT_DIR").unwrap();
- // Copy *.dll & .lib to the output path
- let dll_src: String = String::from("./platforms/win/DynamsoftBarcodeReaderx64.dll");
- let dll_dest_path = Path::new(&out_dir).join("DynamsoftBarcodeReaderx64.dll");
- let _dll_result = fs::copy(dll_src, dll_dest_path);
- let lib_src: String = String::from("./platforms/win/DBRx64.lib");
- let lib_dest_path = Path::new(&out_dir).join("DBRx64.lib");
- let _lib_result = fs::copy(lib_src, lib_dest_path);
- println!("cargo:rustc-link-search={}", &out_dir);
- println!("cargo:rustc-link-lib=DBRx64");
- }
Add Comment
Please, Sign In to add comment