Skip to content

windows-bindgen can't resolve namespaces #4925

Closed

Description

@Cinimajig

Summary

windows-bindgen fails, to resolve namespaces. Even if I swap it out, for another. It can find individual structs, functions just fine.

The Windows.Win32.System.Com was copied from the readme, so I know that's not a typo. Windows.Win32.Networking.ActiveDirectory was one that I copied from an older project, that used windows-rs 0.62, so that should be right.

I also tried adding .input_default(), but that didn't change anything.

Error:

error: failed to run custom build command for `ad-walker v0.1.0 (C:\nerd_stuff\rust\ad-walker)`

Caused by:
  process didn't exit successfully: `C:\nerd_stuff\rust\ad-walker\target\debug\build\ad-walker-c773547f9cb46378\build-script-build` (exit code: 101)
  --- stderr

  thread 'main' (26304) panicked at C:\rust-lang\cargo\registry\src\index.crates.io-1949cf8c6b5b557f\windows-bindgen-0.100.0\src\filter_parser.rs:163:21:
  could not resolve filter entry `Windows::Win32::System::Com`
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Crate manifest

[package]
name = "ad-walker"
version = "0.1.0"
edition = "2024"

[build-dependencies]
windows-bindgen = "0.100.0"

[dependencies]
windows-core = "0.100.0"
windows-link = "0.100.0"

Crate code

// build.rs

fn main() {
    let out_dir = std::env::var("OUT_DIR").unwrap();
    let bindings = format!("{out_dir}/bindings.rs");

    windows_bindgen::builder()
    .filters(&[
        "Windows.Win32.System.Com",
        "Windows.Win32.Networking.ActiveDirectory",
    ])
    .output(&bindings)
    .flat()
    .write();
}

Activity

  1. kennykerr commented on Sep 14, 2026

    @kennykerr
    Collaborator

    The docs need to be improved - sorry about that.

    You should be able to just remove the namespace prefix entirely - windows-bindgen will find the best match. Technically, all of the non-WinRT types now appear in the Windows.Win32 namespace as this represents the "global" namespace in metadata.

    So for example, you can use Windows.Win32.CoCreateInstance if you'd prefer to be explicit or just CoCreateInstance and it will work just as well.

  2. Cinimajig commented on Sep 14, 2026

    @Cinimajig
    Author

    That works, but I don't want to set many filters, if 2 can do the job. I just need everything inside those 2 namespaces (especially ActiveDirectory). Is there an easier way, other than typing all the functions and constants?

  3. changed the title [-]windows-bindgen can't resolve namespaces[/-] [+]`windows-bindgen` can't resolve namespaces[/+] on Sep 14, 2026
  4. kennykerr commented on Sep 14, 2026

    @kennykerr
    Collaborator

    If you'd rather not filter APIs specifically, you may want to consider using the umbrella crate that provides groupings based on the headers that the APIs originate in. https://github.com/microsoft/windows-rs/blob/master/docs/crates/windows.md

  5. LastExceed commented on Sep 18, 2026

    @LastExceed

    Why was this feature removed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions