-
下载rsrc
执行
go get github.com/akavel/rsrc
下载syso文件生成工具的源码,并使用go install
进行编译安装 -
编写main.manifest 配置文件,与main函数所在文件同级
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> <assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="SomeFunkyNameHere" type="win32"/> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/> </dependentAssembly> </dependency> <asmv3:application> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true </asmv3:windowsSettings> </asmv3:application> </assembly>
-
制作main.ico图标,与main函数所在文件同级。
-
下载gcc (可能需要)
-
生成图标配置文件 main.syso
rsrc -arch amd64 -manifest main.manifest -ico main.ico -o main.syso
需要加上
arch amd64
,不然回报is incompatible with i386:x86-64 output
错误 -
编译可执行文件
go build -ldflags "-s -w" -o myapp.exe
go语言打包带图标的windows可执行程序
最新推荐文章于 2024-06-12 18:59:39 发布