scap icon indicating copy to clipboard operation
scap copied to clipboard

expected *mut c_void, found isize

Open MrMarnic opened this issue 1 year ago • 5 comments

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 {
    |                  ^^^^^^^^^^^^^^^^^


MrMarnic avatar Sep 22 '24 21:09 MrMarnic

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 avatar Sep 23 '24 13:09 BenedictWilkins

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

BenedictWilkins avatar Sep 23 '24 13:09 BenedictWilkins

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

MrMarnic avatar Sep 23 '24 16:09 MrMarnic

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?

MrMarnic avatar Sep 23 '24 16:09 MrMarnic

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

BenedictWilkins avatar Sep 23 '24 16:09 BenedictWilkins

Fixed by #120

Brendonovich avatar Nov 07 '24 06:11 Brendonovich