Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compiling on mac os. #134

Open
The-Real-Thisas opened this issue Jul 21, 2023 · 9 comments
Open

Not compiling on mac os. #134

The-Real-Thisas opened this issue Jul 21, 2023 · 9 comments

Comments

@The-Real-Thisas
Copy link

Cargo.toml

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

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

[dependencies]

[dependencies.nokhwa]
version = "0.10.0"
# Use the native input backends, enable WGPU integration
features = ["input-native", "output-wgpu"]

main.rs

fn main () {
    // first camera in system
    let index = CameraIndex::Index(0); 
    // request the absolute highest resolution CameraFormat that can be decoded to RGB.
    let requested = RequestedFormat::new::<RgbFormat>(RequestedFormatType::AbsoluteHighestFrameRate);
    // make the camera
    let mut camera = Camera::new(index, requested).unwrap();

    // get a frame
    let frame = camera.frame().unwrap();
    println!("Captured Single Frame of {}", frame.buffer().len());
    // decode into an ImageBuffer
    let decoded = frame.decode_image::<RgbFormat>().unwrap();
    println!("Decoded Frame of {}", decoded.len());
}

Output

(base)  ~/Desktop/cs/rust/ [master] cargo run
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
   Compiling nokhwa-core v0.1.2
   Compiling wgpu-hal v0.14.1
error[E0308]: mismatched types
   --> /Users/thisas/.cargo/registry/src/github.com-1ecc6299db9ec823/nokhwa-core-0.1.2/src/traits.rs:230:32
    |
230 |                 bytes_per_row: width_nonzero,
    |                                ^^^^^^^^^^^^^ expected enum `Option`, 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/thisas/.cargo/registry/src/github.com-1ecc6299db9ec823/nokhwa-core-0.1.2/src/traits.rs:231:33
    |
231 |                 rows_per_image: height_nonzero,
    |                                 ^^^^^^^^^^^^^^ expected enum `Option`, 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`.
error: could not compile `nokhwa-core` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
(base)  ~/Desktop/cs/rust/ [master] 
@pcontezini
Copy link

Same thing here, to fix (not tested thought) just do what the compiler says:
Line 230: bytes_per_row: Some(width_nonzero),
Line 231: rows_per_image: Some(height_nonzero),

@Kofituo
Copy link

Kofituo commented Oct 13, 2023

Facing this issue as well

@ahirner
Copy link

ahirner commented Oct 14, 2023

I think this can be closed after #142 and thus is duplicated by #141.

@mangoleaf
Copy link

I agree that it can be closed, but it would also be nice if 0.10.5 crate was released so people don't have to pull directly from the git repo for the fix

@Kofituo
Copy link

Kofituo commented Nov 27, 2023

@mangoleaf @ahirner Actually, this issue still stands even to the date. I'm using M1 mac if that helps.

@mangoleaf
Copy link

@Kofituo The fix was merged in #142, but the rust crate was never released since. This worked for me when I checked out the latest code instead of trying to get the crate via crates.io. I am also on an M1 mac.

@Kofituo
Copy link

Kofituo commented Dec 12, 2023

@mangoleaf @ahirner That's surprising. Here's my full project https://github.com/Kofituo/sample_gui/blob/master

Here's the full list of errors I'm facing. They're mostly syntax errors, among others:

// cargo run
   Compiling nokhwa-core v0.2.0 (https://github.com/l1npengtul/nokhwa.git#f0bbbf32)
error: expected one of `(`, `.`, `::`, `;`, `?`, `}`, or an operator, found `:`
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:20:35
    |
20  |                         self.$name: Option<Range<$range_type>> = Some(Range {
    |                                   ^ expected one of 7 possible tokens
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected one of `(`, `.`, `::`, `;`, `?`, `}`, or an operator, found `:`
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:45:35
    |
45  |                         self.$name: Option<Range<$range_type>> = Some(Range {
    |                                   ^ expected one of 7 possible tokens
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected one of `(`, `.`, `::`, `;`, `?`, `}`, or an operator, found `:`
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:60:35
    |
60  |                         self.$name: Option<Range<$range_type>> = Some(Range {
    |                                   ^ expected one of 7 possible tokens
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected one of `(`, `.`, `::`, `;`, `?`, `}`, or an operator, found `:`
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:76:35
    |
76  |                         self.$name: Option<Range<$range_type>> = Some(Range {
    |                                   ^ expected one of 7 possible tokens
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected one of `(`, `.`, `::`, `;`, `?`, `}`, or an operator, found `:`
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:91:35
    |
91  |                         self.$name: Option<Range<$range_type>> = Some(Range {
    |                                   ^ expected one of 7 possible tokens
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected one of `(`, `.`, `::`, `;`, `?`, `}`, or an operator, found `:`
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:115:35
    |
115 |                         self.$name: Option<Range<$range_type>> = Some(Range {
    |                                   ^ expected one of 7 possible tokens
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected `;`, found keyword `Self`
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:125:35
    |
125 |                 self.$name = $name
    |                                   ^ help: add `;` here
126 |                 Self
    |                 ---- unexpected token
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `self` parameter is only allowed in associated functions
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:14:46
    |
14  |             pub fn [< with_maximum_ $name >](mut self, $name: $range_type) -> Self {
    |                                              ^^^^^^^^ not semantically valid as function parameter
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: associated functions are those in `impl` or `trait` definitions
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `self` parameter is only allowed in associated functions
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:30:47
    |
30  |             pub fn [< reset_maximum_ $name >](mut self) -> Self {
    |                                               ^^^^^^^^ not semantically valid as function parameter
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: associated functions are those in `impl` or `trait` definitions
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `self` parameter is only allowed in associated functions
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:39:45
    |
39  |             pub fn [< set_maximum_ $name >](&mut self, $name: Option<$range_type>) {
    |                                             ^^^^^^^^^ not semantically valid as function parameter
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: associated functions are those in `impl` or `trait` definitions
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `self` parameter is only allowed in associated functions
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:54:48
    |
54  |             pub fn [< with_preferred_ $name >](mut self, $name: $range_type) -> Self {
    |                                                ^^^^^^^^ not semantically valid as function parameter
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: associated functions are those in `impl` or `trait` definitions
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `self` parameter is only allowed in associated functions
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:70:47
    |
70  |             pub fn [< set_preferred_ $name >](&mut self, $name: $range_type) {
    |                                               ^^^^^^^^^ not semantically valid as function parameter
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: associated functions are those in `impl` or `trait` definitions
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `self` parameter is only allowed in associated functions
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:85:46
    |
85  |             pub fn [< with_minimum_ $name >](mut self, $name: $range_type) -> Self {
    |                                              ^^^^^^^^ not semantically valid as function parameter
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: associated functions are those in `impl` or `trait` definitions
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `self` parameter is only allowed in associated functions
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:101:47
    |
101 |             pub fn [< reset_minimum_ $name >](mut self) -> Self {
    |                                               ^^^^^^^^ not semantically valid as function parameter
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: associated functions are those in `impl` or `trait` definitions
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `self` parameter is only allowed in associated functions
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:109:45
    |
109 |             pub fn [< set_minimum_ $name >](&mut self, $name: Option<$range_type>) {
    |                                             ^^^^^^^^^ not semantically valid as function parameter
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: associated functions are those in `impl` or `trait` definitions
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `self` parameter is only allowed in associated functions
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:124:45
    |
124 |             pub fn [< with_ $name _range >](mut self, $name: Option<Range<$range_type>>) -> Self {
    |                                             ^^^^^^^^ not semantically valid as function parameter
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: associated functions are those in `impl` or `trait` definitions
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `self` parameter is only allowed in associated functions
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:129:44
    |
129 |             pub fn [< set_ $name _range >](&mut self, $name: Option<Range<$range_type>>) {
    |                                            ^^^^^^^^^ not semantically valid as function parameter
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: associated functions are those in `impl` or `trait` definitions
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: use of undeclared crate or module `serde`
 --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/decoder.rs:3:5
  |
3 | use serde::de::Error;
  |     ^^^^^ use of undeclared crate or module `serde`

error[E0432]: unresolved import `crate::frame_format::SourceFrameFormat`
  --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/buffer.rs:17:13
   |
17 | use crate::{frame_format::SourceFrameFormat, types::Resolution};
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `SourceFrameFormat` in `frame_format`

error[E0432]: unresolved import `crate::frame_format::SourceFrameFormat`
 --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:1:5
  |
1 | use crate::frame_format::SourceFrameFormat;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `SourceFrameFormat` in `frame_format`

error[E0432]: unresolved imports `crate::format_request::FormatFilter`, `crate::frame_format::SourceFrameFormat`
  --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/traits.rs:20:5
   |
20 |     format_request::FormatFilter,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `FormatFilter` in `format_request`
21 |     frame_format::SourceFrameFormat,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `SourceFrameFormat` in `frame_format`

error[E0412]: cannot find type `RgbAFormat` in this scope
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/buffer.rs:173:50
    |
173 |         let frame = self.frame()?.decode_image::<RgbAFormat>()?;
    |                                                  ^^^^^^^^^^ not found in this scope
    |
help: you might be missing a type parameter
    |
162 | impl<RgbAFormat> Buffer {
    |     ++++++++++++

error[E0411]: cannot find type `Self` in this scope
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:14:79
    |
14  |             pub fn [< with_maximum_ $name >](mut self, $name: $range_type) -> Self {
    |                    ------------------------- `Self` not allowed in a function ^^^^ `Self` is only available in impls, traits, and type definitions
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0411]: cannot find type `Self` in this scope
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:30:60
    |
30  |             pub fn [< reset_maximum_ $name >](mut self) -> Self {
    |                    --------------------------              ^^^^ `Self` is only available in impls, traits, and type definitions
    |                    |
    |                    `Self` not allowed in a function
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0411]: cannot find type `Self` in this scope
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:54:81
    |
54  |             pub fn [< with_preferred_ $name >](mut self, $name: $range_type) -> Self {
    |                    --------------------------- `Self` not allowed in a function ^^^^ `Self` is only available in impls, traits, and type definitions
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0411]: cannot find type `Self` in this scope
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:85:79
    |
85  |             pub fn [< with_minimum_ $name >](mut self, $name: $range_type) -> Self {
    |                    ------------------------- `Self` not allowed in a function ^^^^ `Self` is only available in impls, traits, and type definitions
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0411]: cannot find type `Self` in this scope
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:101:60
    |
101 |             pub fn [< reset_minimum_ $name >](mut self) -> Self {
    |                    --------------------------              ^^^^ `Self` is only available in impls, traits, and type definitions
    |                    |
    |                    `Self` not allowed in a function
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0411]: cannot find type `Self` in this scope
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:124:93
    |
124 |             pub fn [< with_ $name _range >](mut self, $name: Option<Range<$range_type>>) -> Self {
    |                    ------------------------ `Self` not allowed in a function                ^^^^ `Self` is only available in impls, traits, and type definitions
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find value `Self` in this scope
   --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/format_request.rs:126:17
    |
126 |                 Self
    |                 ^^^^ help: a local variable with a similar name exists (notice the capitalization): `self`
...
210 | range_set_fields!((Resolution, resolution), (u32, frame_rate),);
    | --------------------------------------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `range_set_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0223]: ambiguous associated type
  --> /Users/kofiotuo/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/f0bbbf3/nokhwa-core/src/decoder.rs:14:37
   |
14 |     type Container: Deref<Target = [Pixel::Subpixel]>;
   |                                     ^^^^^^^^^^^^^^^
   |
help: if there were a type named `Example` that implemented `Pixel`, you could use the fully-qualified path
   |
14 |     type Container: Deref<Target = [<Example as Pixel>::Subpixel]>;
   |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Some errors have detailed explanations: E0223, E0411, E0412, E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0223`.
error: could not compile `nokhwa-core` (lib) due to 30 previous errors

@MohammadKurjieh
Copy link

@Kofituo I was facing the same issue on mac m1, but using the pull #142, commit "8987af8", It compiles fine on my machine.

@The-Real-Thisas
Copy link
Author

@MohammadKurjieh I guess the crate just isn't updated ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants