Skip to content

raw-dylib doesn't work on Windows with x86_64-pc-windows-gnu #140704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ColinFinck opened this issue May 6, 2025 · 1 comment
Closed

raw-dylib doesn't work on Windows with x86_64-pc-windows-gnu #140704

ColinFinck opened this issue May 6, 2025 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@ColinFinck
Copy link
Contributor

Note: This is the same bug as #103939.
But now it also happens when compiling on Windows using the x86_64-pc-windows-gnu toolchain and compiling for x86_64-pc-windows-gnu. This is a common default scenario without any cross-compiling involved.

I tried this code:

fn main() {
    unsafe {
        MessageBoxA(0, b"hello\0".as_ptr(), "world\0".as_ptr(), 0);
    }
}

#[link(name = "user32", kind = "raw-dylib")]
unsafe extern "system" {
    fn MessageBoxA(hwnd: usize, lptext: *const u8, lpcaption: *const u8, flags: u32) -> i32;
}

I expected to see this happen:
Successful compilation

Instead, this happened:

C:\wintest>cargo build
   Compiling wintest v0.1.0 (C:\wintest)
error: Error calling dlltool 'dlltool.exe': program not found

error: could not compile `wintest` (bin "wintest") due to 1 previous error

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (2e6882ac5 2025-05-05)
binary: rustc
commit-hash: 2e6882ac5be27a73293d6f7ae56397fdf32848de
commit-date: 2025-05-05
host: x86_64-pc-windows-gnu
release: 1.88.0-nightly
LLVM version: 20.1.4

Workaround

The same workaround as discussed in #103939 also works for this issue: Putting an LLVM dlltool renamed to dlltool.exe in your PATH.
This was considered fine as a temporary workaround in #103939, because fixing the cross-compilation issue didn't seem urgent. However, this is now affecting the default compilation on x86_64-pc-windows-gnu, hence I hope for a permanent fix soon.

@ColinFinck ColinFinck added the C-bug Category: This is a bug. label May 6, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 6, 2025
@workingjubilee
Copy link
Member

Sorry, closing as duplicate.

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants