Two ways to build a windows GUI executable file without console window


add these lines at the begin of your sorce file:

#[link_args = "-Wl,--subsystem,windows"]
extern "C" {}

->run cmd.exe
->cd into your project dir
->mkdir .cargo
then create a config file with these:

rustflags = ["-C", "link-args=-mwindows "]


Windows Subsystem feature is expected to be included in Rust 1.18, so this will become easier.


note that link-args=-mwindows works only on gnu and -Wl,--subsystem,windows only works on msvc.


I’m pretty sure neither of those work in msvc. What does work in msvc is /SUBSYSTEM:WINDOWS, although you really should be using the new windows subsystem crate attribute.