Go编译器有窗口设置选项吗?

huangapple go评论76阅读模式
英文:

Is there a windowed setting option for the Go compiler?

问题

我正在使用Go(6g)编译一个GTK应用程序,我想知道是否有编译器/链接器选项可以将其制作为Windows可执行文件,而不是控制台可执行文件。MinGW有一个-mwindows选项可以实现这一点,目前我不得不使用十六进制编辑器手动修改PE头,这很麻烦。

英文:

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

得分: 8

-ldflags 'flag list' 每个5l、6l或8l链接器调用的参数

-ldflags -Hwindowsgui添加到go build/get/install命令行中。例如,

go build -ldflags="-Hwindowsgui" gtkapp.go
英文:

> -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

答案2

得分: 1

这个旧答案对我不起作用。这个可以:

go build -ldflags -H=windowsgui gtkapp.go
英文:

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

go build -ldflags -H=windowsgui gtkapp.go

huangapple
  • 本文由 发表于 2012年7月9日 17:04:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/11391975.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定