Quickstart

Rust for Windows quickstart — first native app guide

To build your first native Windows app with Rust: install rustup, run cargo new my-app, add the windows crate to Cargo.toml, and call Win32 or WinRT APIs from main.rs. A basic app compiles in under 30 seconds.

Your first Rust app on Windows

PowerShell
PS> cargo new hello-win && cd hello-win
PS> cargo run
Compiling hello-win v0.1.0
Finished dev profile [unoptimized + debuginfo]
Hello, world!

Use Win32 APIs with the windows crate

Add windows to your Cargo.toml:

Cargo.toml
[dependencies]
windows = { version = "0.57", features = [
"Win32_UI_WindowsAndMessaging",
"Win32_Foundation",
] }

Call a Win32 API from src/main.rs:

src/main.rs
use windows::Win32::UI::WindowsAndMessaging::MessageBoxW;
use windows::Win32::Foundation::HWND;
use windows::core::w;
fn main() {
unsafe {
MessageBoxW(HWND(0), w!("Hello from Rust!"), w!("Test"), Default::default());
}
}

Build a release binary

PowerShell
# Debug build (fast compile, large binary):
PS> cargo build
# Output: target\debug\hello-win.exe
# Release build (optimised, smaller binary):
PS> cargo build --release
# Output: target\release\hello-win.exe

Quickstart questions

How long does Rust compilation take on Windows?

A fresh debug build of a "Hello, world!" app takes 5–15 seconds. Incremental builds (after changing one file) take under 1 second. Adding the windows crate increases the first compile to 30–90 seconds due to the large API surface. Release builds with LTO take 2–5x longer than debug builds.

How to open a window with Rust on Windows?

For a native Win32 window, use the windows crate and call CreateWindowExW. For a simpler cross-platform approach, use winit (event loop) with a renderer like egui or wgpu. See the GUI development guide.