twistedfall / opencv-rust

Rust bindings for OpenCV 3 & 4
MIT License
1.97k stars 160 forks source link

Build failed on MacOS #129

Closed higumachan closed 4 years ago

higumachan commented 4 years ago

Hi I met build error on Mac OS. I looks some problem about LLVM. I want to help.

These are my scenario.

item desc
OS MacOS 10.14.6
OpenCV 4 directory /usr/local/Cellar/opencv/4.3.0
opencv-rust features buildtime-bindgen,contrib
How to install Opencv brew install opencv
llvm directory /usr/local/Cellar/llvm/7.0.1/

And, this is a my build log.

fail.log

thanks.

twistedfall commented 4 years ago

Are you using clang_sys with runtime feature enabled somewhere in your Cargo.toml or dependencies? That combination wasn't working for me in multithreaded generation so it's known to be broken at the moment.

higumachan commented 4 years ago

Thank you for response.

I look there doesn't seem to be a clang_sys with "runtime" feature dependency.

these are Cargo.toml files by I wrote.

[package]
name = "dobot-rs"
version = "0.1.0"
authors = ["higumachan <harekumo792154@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

members = [
    "libdobot",
]

[dependencies]
libdobot = { path = "./libdobot" }
opencv = {version = "0.36", features = ["buildtime-bindgen"]}
tokio = { version = "0.2.21", features = ["full"] }
[package]
name = "libdobot"
version = "0.1.0"
authors = ["higumachan <harekumo792154@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
bindgen = "^0.53"
cmake = "0.1"

[dependencies]
strum = "^0.18"
strum_macros = "^0.18"
tokio = { version = "^0.2", features = ["time"] }
twistedfall commented 4 years ago

Ah, it's bindgen, from its Cargo.toml:

[features]
default = [... "runtime" ...]
runtime = ["clang-sys/runtime"]

I'll see what can be done, but in the meanwhile you can do a quick fix, in the build.rs change line:

modules.par_iter().for_each(|module| {

to read:

modules.iter().for_each(|module| {

and in the binding-generator/Cargo.toml make the lines read:

clang = {version = "0.23", features = ["runtime", "clang_6_0"]}
clang-sys = {version = "0.28", features = ["runtime", "clang_6_0"]}

The build will be slower, but it should get past the generation phase.

higumachan commented 4 years ago

Thank you for response.

I have successfully built 🎉

Can I contribute this way? My idea is add nonparallel feature.

twistedfall commented 4 years ago

Yes, please do! But please call the feature clang-runtime. Because it’s not about being parallel (there are other still other parts that are done in parallel), but about compatibility with clang.

higumachan commented 4 years ago

OK! I will implement new feature call by clang-runtime.

Please wait a few days. thanks.

twistedfall commented 4 years ago

Thank you!