Skip to content
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

Linker error when cross compiling on Linux for Windows #1051

Closed
WyattEnrich opened this issue Jan 26, 2024 · 1 comment
Closed

Linker error when cross compiling on Linux for Windows #1051

WyattEnrich opened this issue Jan 26, 2024 · 1 comment

Comments

@WyattEnrich
Copy link

WyattEnrich commented Jan 26, 2024

Hello,

I am using winapi to validate the authenticode signature on executables (via https://docs.rs/codesign-verify/). When I cross compile on Mac for Windows, it works fine; when I cross compile on Linux for Windows, it fails with a linker error:

note: /usr/bin/x86_64-w64-mingw32-ld: cannot find -lWintrust

A simple test case follows:

Cargo.toml:

[package]
name = "test"
version = "0.1.0"
edition = "2018"

[dependencies]
codesign-verify = "0.1.2"

main.rs:

extern crate codesign_verify;

use codesign_verify::CodeSignVerifier;

fn main() {
	let path = "C:/Windows/explorer.exe";
	CodeSignVerifier::for_file(path).unwrap().verify().unwrap();
	println!("Success");
}

On the build system (Linux) I have installed Rust, added the x86_64-pc-windows-gnu target, and installed mingw-w64.

rustup target add x86_64-pc-windows-gnu
sudo apt-get install mingw-w64

I build with command:

cargo build --target=x86_64-pc-windows-gnu

The error log is attached:
error.txt

Do you have any idea how to get around this? I can't think why an OSX build machine would work while Linux does not. We unfortunately need to build on our Linux dev server.

Thank you very much!

@WyattEnrich
Copy link
Author

This turned out to be an issue with codesign-verify. Sorry for the ticket!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant