Chris_F
Chris_F

Reputation: 5557

Is there a windowed setting option for the Go compiler?

I'm using Go (6g) to compile a GTK application and I want to know if there is a compiler/linker option to make it a Windows executable as opposed to console executable. MinGW has a -mwindows option for this and currently I'm having to manually alter the PE header with a hex editor which is annoying.

Upvotes: 7

Views: 1850

Answers (2)

Anthony V
Anthony V

Reputation: 2227

The old answer does not work for me. This works:

go build -ldflags -H=windowsgui gtkapp.go

Upvotes: 1

peterSO
peterSO

Reputation: 166569

-ldflags 'flag list' arguments to pass on each 5l, 6l, or 8l linker invocation

Compile packages and dependencies

-Hwindowsgui (only in 6l/8l) Write Windows PE32+ GUI binaries

Command ld

Add -ldflags -Hwindowsgui to the go build/get/install command line. For example,

go build -ldflags="-Hwindowsgui" gtkapp.go

Upvotes: 8

Related Questions