retep998 / winapi-rs

Rust bindings to Windows API
https://crates.io/crates/winapi
Apache License 2.0
1.85k stars 392 forks source link

use of undeclared crate or module `winapi` / could not find `um` in `winapi` #1029

Closed rob-scheepens closed 2 years ago

rob-scheepens commented 2 years ago

I'm trying to use the PDH definitions provided by winapi. With this Cargo.toml, I get "use of undeclared crate or module winapi":

[package]
name = "windows-disk-exporter"
version = "0.1.0"
edition = "2021"

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

[dependencies]
prometheus = "0.13.2"

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", features = ["pdh"] }

[dependencies.windows]
version =  "0.42.0"
features = [
    "Win32_System_Performance",
]

Adding winapi to the dependencies however, gives me "could not find um in winapi":

[package]
name = "windows-disk-exporter"
version = "0.1.0"
edition = "2021"

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

[dependencies]
prometheus = "0.13.2"
winapi = { version = "0.3.9", features = ["pdh"] }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", features = ["pdh"] }

[dependencies.windows]
version =  "0.42.0"
features = [
    "Win32_System_Performance",
]

I know I am missing something as I am new to Rust, but what?

rob-scheepens commented 2 years ago

The issue was that on the Mac I compiled on, mingw is not installed. Compiling on a Windows vm with mingw works fine.