Skip to content

Windows build fails: unresolved import GetWindowText, HWND not found #8

@Wooklae-cho

Description

@Wooklae-cho

Description

Building tauri-mcp on Windows fails with compilation errors in the Windows-specific code.

Environment

  • OS: Windows
  • Rust: Latest stable
  • Version: v0.1.4 (crates.io) and v0.1.5 (GitHub main)

Error Output

error[E0432]: unresolved import `windows::Win32::UI::WindowsAndMessaging::GetWindowText`
  --> src\tools\window.rs:22:62
   |
22 | use windows::Win32::UI::WindowsAndMessaging::{GetWindowRect, GetWindowText, GetWindowTextLengthW};
   |                                                              ^^^^^^^^^^^^^
   |                                                              no `GetWindowText` in `Win32::UI::WindowsAndMessaging`
   |                                                              help: a similar name exists in the module: `GetWindowTextA`

error[E0412]: cannot find type `HWND` in this scope
  --> src\utils\platform.rs:37:54
   |
37 | unsafe extern "system" fn enum_window_callback(hwnd: HWND, lparam: isize) -> i32 {
   |                                                      ^^^^ not found in this scope

error[E0308]: mismatched types
  --> src\utils\platform.rs:27:18
   |
27 |             Some(enum_window_callback),
   |             ---- ^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
   |
   = note: expected fn pointer `unsafe extern "system" fn(HWND, LPARAM) -> BOOL`
                 found fn item `unsafe extern "system" fn({type error}, isize) -> i32 {enum_window_callback}`

error[E0277]: the trait bound `isize: IntoParam<LPARAM, CopyType>` is not satisfied

Root Cause

  1. GetWindowText doesn't exist in windows crate v0.52.0 - should use GetWindowTextW (Unicode) or GetWindowTextA (ANSI)
  2. HWND type needs to be imported from windows::Win32::Foundation::HWND in platform.rs
  3. Callback function signature and LPARAM parameter handling issues

Suggested Fix

Update the Windows API usage to match windows crate v0.52.0 API:

  • Use GetWindowTextW instead of GetWindowText
  • Import HWND properly in platform.rs
  • Fix callback signature to use LPARAM type

Workaround

Currently no workaround for direct cargo install on Windows. The DXT package with Node.js wrapper is recommended for Claude Desktop users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions