-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild.rs
More file actions
34 lines (26 loc) · 1.09 KB
/
build.rs
File metadata and controls
34 lines (26 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::process::Command;
use std::env;
use std::path::Path;
use std::fs::File;
use std::io::Write;
fn try_gcc(lib: &str, msg: &str) {
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("main.c");
let mut f = File::create(&dest_path).unwrap();
f.write_all(b"
int main() {
}
").unwrap();
let s = Command::new("gcc")
.args(&[dest_path.into_os_string().to_str().unwrap(), lib, "-o"])
.arg(&format!("{}/main.o", out_dir))
.status()
.unwrap();
assert!(s.success(), "\n\n".to_string() + msg);
}
fn main() {
try_gcc("-lblas", "BLAS not found. On Ubuntu try 'sudo apt-get install libblas3' before continuing.");
try_gcc("-lopencv_highgui", "OpenCV not found. On Ubuntu try 'sudo apt-get install libopencv-highgui-dev' before continuing.");
try_gcc("-lopencv_core", "OpenCV not found. On Ubuntu try 'sudo apt-get install libopencv-core2.4' before continuing.");
try_gcc("-lopencv_imgproc", "OpenCV not found. On Ubuntu try 'sudo apt-get install libopencv-imgproc2.4' before continuing.");
}