l1npengtul / nokhwa

Cross Platform Rust Library for Powerful Webcam/Camera Capture
Apache License 2.0
465 stars 110 forks source link

failed to run custom build command for `v4l2-sys-mit v0.2.0` #174

Open zxcqirara opened 1 month ago

zxcqirara commented 1 month ago

Just created a new project, added this lib and tried to compile it. It throws this error:

error: failed to run custom build command for `v4l2-sys-mit v0.2.0`

Caused by:
  process didn't exit successfully: `/home/user/proj/target/debug/build/v4l2-sys-mit-844fdf7983ccc2a0/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.56.0/src/ir/context.rs:846:9:
  "v4l2_pix_format_union_(anonymous_at_/usr/sbin/__/lib64/gcc/aarch64-linux-gnu/14_1_0/__/__/__/__/aarch64-linux-gnu/include/linux/videodev2_h_500_2)" is not a valid Ident
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm on x64 linux (WSL) and trying to compile it for aarch64 linux My Cargo.toml:

[package]
name = "proj"
version = "0.1.0"
edition = "2021"

[dependencies]
nokhwa = { version = "0.10.4", features = ["input-native", "output-threaded"] }
unwx commented 1 week ago

I encountered the same build failure. The root cause explained here: https://stackoverflow.com/a/76443281

I'm new to Rust, but it looks like:


Workaround:

Building nokhwa from source (the 0.10 branch) resolved the issue for me.

Additional Notes:

On Fedora, I needed to install the following development packages for the build to succeed:

fontconfig-devel, alsa-lib-devel, libudev-devel