How to build a Rust application for Windows on Linux? Cross-compilation from scratch
Hello everyone! I'm writing a small CLI application in Rust on Linux, but I need it to work on Windows as well. The problem is that I don't want to switch to Windows just for building — I want to compile an exe file directly from Ubuntu.\n\nI added the `x86_64-pc-windows-gnu` target via `rustup target add`, but when trying to build with `cargo build --target x86_64-pc-windows-gnu`, I get a bunch of linking errors, like:\n\n```\nerror: linking with `x86_64-w64-mingw32-gcc` failed: exit status: 1\n | \n = note: /usr/bin/x86_64-w64-mingw32-ld: cannot find -ladvapi32\n /usr/bin/x86_64-w64-mingw32-ld: cannot find -luserenv\n```\n\nI read that MinGW-w64 is needed, installed it via apt, but the errors persist. I also tried installing `mingw-w64` — it didn't help. My code is simple:\n\n```rust\nuse std::process
No answers yet.
Log in to leave an answer