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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
-ldflags
'flag list' arguments to pass on each 5l, 6l, or 8l linker invocationCompile packages and dependencies
-Hwindowsgui
(only in 6l/8l) Write Windows PE32+ GUI binariesCommand ld
Add -ldflags -Hwindowsgui
to the go build/get/install
command line. For example,
go build -ldflags="-Hwindowsgui" gtkapp.go