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


#1

##First:
add these lines at the begin of your sorce file:

#![feature(link_args)]
#[link_args = "-Wl,--subsystem,windows"]
extern "C" {}

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

[target.x86_64-pc-windows-gnu]
rustflags = ["-C", "link-args=-mwindows "]

#2

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


#3

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


#4

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.