l1npengtul / nokhwa

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

Build Error: error[E0308]: mismatched types - Apple M2 #141

Closed aaqidmasoodi closed 1 month ago

aaqidmasoodi commented 10 months ago

rustc 1.72.0 cargo 1.72.0 macos ventura - apple silicon m2 output of cargo build -vv after Compiling nokhwa-core v0.1.2

Compiling nokhwa-core v0.1.2
     Running `CARGO=/Users/aaqidmasoodi/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo CARGO_CRATE_NAME=nokhwa_core CARGO_MANIFEST_DIR=/Users/aaqidmasoodi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nokhwa-core-0.1.2 CARGO_PKG_AUTHORS='l1npengtul <l1npengtul@protonmail.com>' CARGO_PKG_DESCRIPTION='Core type definitions for nokhwa' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=nokhwa-core CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='https://github.com/l1npengtul/nokhwa' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.2 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=2 CARGO_PKG_VERSION_PRE='' DYLD_FALLBACK_LIBRARY_PATH='/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps:/Users/aaqidmasoodi/.rustup/toolchains/stable-aarch64-apple-darwin/lib:/Users/aaqidmasoodi/.rustup/toolchains/stable-aarch64-apple-darwin/lib:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/' /Users/aaqidmasoodi/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc --crate-name nokhwa_core --edition=2021 /Users/aaqidmasoodi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nokhwa-core-0.1.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=87 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --cfg 'feature="default"' --cfg 'feature="mjpeg"' --cfg 'feature="mozjpeg"' --cfg 'feature="wgpu"' --cfg 'feature="wgpu-types"' -C metadata=5e713587c34f4dac -C extra-filename=-5e713587c34f4dac --out-dir '/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps' -L 'dependency=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps' --extern 'bytes=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps/libbytes-63d4607b3cb51af4.rmeta' --extern 'image=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps/libimage-15cd89847b91c4f5.rmeta' --extern 'mozjpeg=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps/libmozjpeg-cc4e73f195ba5f2d.rmeta' --extern 'thiserror=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps/libthiserror-072957a7e80bcc85.rmeta' --extern 'wgpu=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps/libwgpu-7d762e9691332996.rmeta' --cap-lints warn -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -L 'native=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/build/mozjpeg-sys-64a0042bba489b59/out' -L 'native=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/build/mozjpeg-sys-64a0042bba489b59/out' -L 'native=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/build/objc_exception-d1c10659c506bb06/out'`
warning: unused import: `std::num::NonZeroU32`
   --> /Users/aaqidmasoodi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nokhwa-core-0.1.2/src/traits.rs:196:13
    |
196 |         use std::num::NonZeroU32;
    |             ^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(unused_imports)]` on by default

error[E0308]: mismatched types
   --> /Users/aaqidmasoodi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nokhwa-core-0.1.2/src/traits.rs:230:32
    |
230 |                 bytes_per_row: width_nonzero,
    |                                ^^^^^^^^^^^^^ expected `Option<u32>`, found `u32`
    |
    = note: expected enum `Option<u32>`
               found type `u32`
help: try wrapping the expression in `Some`
    |
230 |                 bytes_per_row: Some(width_nonzero),
    |                                +++++             +

error[E0308]: mismatched types
   --> /Users/aaqidmasoodi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nokhwa-core-0.1.2/src/traits.rs:231:33
    |
231 |                 rows_per_image: height_nonzero,
    |                                 ^^^^^^^^^^^^^^ expected `Option<u32>`, found `u32`
    |
    = note: expected enum `Option<u32>`
               found type `u32`
help: try wrapping the expression in `Some`
    |
231 |                 rows_per_image: Some(height_nonzero),
    |                                 +++++              +

For more information about this error, try `rustc --explain E0308`.
warning: `nokhwa-core` (lib) generated 1 warning
error: could not compile `nokhwa-core` (lib) due to 2 previous errors; 1 warning emitted

Caused by:
  process didn't exit successfully: `CARGO=/Users/aaqidmasoodi/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo CARGO_CRATE_NAME=nokhwa_core CARGO_MANIFEST_DIR=/Users/aaqidmasoodi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nokhwa-core-0.1.2 CARGO_PKG_AUTHORS='l1npengtul <l1npengtul@protonmail.com>' CARGO_PKG_DESCRIPTION='Core type definitions for nokhwa' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=nokhwa-core CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='https://github.com/l1npengtul/nokhwa' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.2 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=2 CARGO_PKG_VERSION_PRE='' DYLD_FALLBACK_LIBRARY_PATH='/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps:/Users/aaqidmasoodi/.rustup/toolchains/stable-aarch64-apple-darwin/lib:/Users/aaqidmasoodi/.rustup/toolchains/stable-aarch64-apple-darwin/lib:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/' /Users/aaqidmasoodi/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc --crate-name nokhwa_core --edition=2021 /Users/aaqidmasoodi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nokhwa-core-0.1.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=87 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --cfg 'feature="default"' --cfg 'feature="mjpeg"' --cfg 'feature="mozjpeg"' --cfg 'feature="wgpu"' --cfg 'feature="wgpu-types"' -C metadata=5e713587c34f4dac -C extra-filename=-5e713587c34f4dac --out-dir '/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps' -L 'dependency=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps' --extern 'bytes=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps/libbytes-63d4607b3cb51af4.rmeta' --extern 'image=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps/libimage-15cd89847b91c4f5.rmeta' --extern 'mozjpeg=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps/libmozjpeg-cc4e73f195ba5f2d.rmeta' --extern 'thiserror=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps/libthiserror-072957a7e80bcc85.rmeta' --extern 'wgpu=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/deps/libwgpu-7d762e9691332996.rmeta' --cap-lints warn -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -L 'native=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/build/mozjpeg-sys-64a0042bba489b59/out' -L 'native=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/build/mozjpeg-sys-64a0042bba489b59/out' -L 'native=/Users/aaqidmasoodi/Documents/rust projects/learn-rust/target/debug/build/objc_exception-d1c10659c506bb06/out'` (exit status: 1)
warning: build failed, waiting for other jobs to finish...

Cargo.toml file

[package]
name = "learn-rust"
version = "0.1.0"
edition = "2021"

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

[dependencies.nokhwa]
version = "0.10.4"
# Use the native input backends, enable WGPU integration
features = ["input-native", "output-wgpu"]
aaqidmasoodi commented 1 month ago

Okay I have fixed it: https://aaqidmasoodi.com/how-to-install-opencv-crate-for-rust-on-macos/