CapSoftware / scap

High-performance, cross-platform screen capture library in Rust.
https://crates.io/crates/scap
Other
229 stars 44 forks source link

expected *mut c_void, found isize #119

Closed MrMarnic closed 2 weeks ago

MrMarnic commented 2 months ago

I am trying to use this library, but I get this error:

error[E0308]: mismatched types
   --> C:\Users\#####\Documents\RustProjects\scap\scap\src\capturer\engine\win\mod.rs:156:42
    |
156 |             WCMonitor::from_raw_hmonitor(display.raw_handle.0),
    |             ---------------------------- ^^^^^^^^^^^^^^^^^^^^ expected `*mut c_void`, found `isize`
    |             |
    |             arguments to this function are incorrect
    |
    = note: expected raw pointer `*mut c_void`
                      found type `isize`
note: associated function defined here
   --> C:\Users\#####\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-capture-1.3.6\src\monitor.rs:440:18
    |
440 |     pub const fn from_raw_hmonitor(monitor: *mut std::ffi::c_void) -> Self {
    |                  ^^^^^^^^^^^^^^^^^
BenedictWilkins commented 2 months ago

weirdly if you clone the repo and run with main.rs then it works, but if you add the repo cargo.toml with your own main.rs then get this error, maybe some versioning weirdness with windows 0.52 or 0.56 api ?

EDIT: when compiling from the cloned repo it uses windows-capture 1.2.0, but otherwise it uses windows-capture 1.3.6 (latest), there is a dependency issue here

EDIT2: If I remove Cargo.lock to have it regenerated after cloning then same error arises...

EDIT3: Confirmed it is an issue with windows-capture versioning, I will create a pull request to update to version 1.3.6 of windows-capture (it seems like a straight-foward issue, but let's see).

BenedictWilkins commented 2 months ago

SOLUTION:

Just update the versions in your Cargo.toml file:

[target.'cfg(target_os = "windows")'.dependencies]
windows-capture = "1.3.6"
windows = { version = "0.58", features = [
    "Win32_Foundation",
    "Win32_Graphics_Gdi",
    "Win32_UI_HiDpi",
    "Win32_UI_WindowsAndMessaging",
] }

EDIT: The versions need to change in a local copy of scap (cloned from github), at least until the pull request (#120) is merged

MrMarnic commented 2 months ago

Thanks for the fast help. I think this guy had the same problem. https://github.com/CapSoftware/scap/issues/112

MrMarnic commented 2 months ago

I still get the same error, even after changing the toml file.

[dependencies]
scap = {path="C:\\Users\\#####\\Documents\\RustProjects\\scap\\scap"}

[target.'cfg(target_os = "windows")'.dependencies]
windows-capture = "1.3.6"
windows = { version = "0.58", features = [
    "Win32_Foundation",
    "Win32_Graphics_Gdi",
    "Win32_UI_HiDpi",
    "Win32_UI_WindowsAndMessaging",
] }

Is it correct?

BenedictWilkins commented 2 months ago

sorry I meant for you to change the version in the local cargo.toml of scap (i.e. not the cargo.toml of your project), ill update the comment

Brendonovich commented 2 weeks ago

Fixed by #120