Closed precisionpete closed 1 year ago
Problem solved. I consulted ChatGPT and got the following answer. My .rc
has more stuff in it. But this was the missing link. I was doing this on Windows. And it never occurred to me that the same tool would be available for Linux...
Cross-compiling a Go program for Windows on a Linux host while also embedding Windows resources such as icons and manifests can be achieved through a few steps. Here's a comprehensive guide on how to do it:
Install Necessary Tools:
mingw-w64
to provide the necessary cross-compilation toolchain.windres
, which is a part of the MinGW package, to compile the Windows resources.Prepare Your Windows Resources:
.rc
file (Windows Resource file) that includes references to your icon, manifest, etc. For example, create a file named resources.rc
with content like:1 ICON "icon.ico"
1 24 "manifest.xml"
Compile the Resource File:
windres
to compile the .rc
file into a .syso
file, which can be automatically included by Go during the build process.x86_64-w64-mingw32-windres -o resources.syso resources.rc
Cross-Compile Your Go Program:
go build
command to cross-compile your Go program for Windows.env GOOS=windows GOARCH=amd64 go build -o output.exe
Verify Your Executable:
output.exe
should be a Windows executable that includes your specified icon and manifest. You can transfer it to a Windows machine to verify.Additional Resources:
This process allows you to embed icons, manifests, and other resources into your Go program while cross-compiling it for Windows on a Linux host. By creating a Windows resource file, compiling it into a .syso
file, and then including that file during the Go build process, you can ensure that your Windows executable has the desired resources embedded.
wails build
should already include the icon and the manifest when doing a cross compile with wails build --platform windows
.
We also compile our Windows app on linux and never had a problem with windows resources not being included.
If you still have problems with this, please feel free to reopen 👍
Wails is fine. This question was more about how to get the Windows resources included in a non-wails go app when cross-compiled on Linux. And the ChatGPT solution worked perfectly.
Since Wails allows me to build a Windows app without Windows, I was trying to get the rest of my app working with the same build process.
Now, if we could only produce a macos app without macos, that would be a triumph. But I suppose that will never happen...
Thanks again for a great product!
So the Wails cli does all that for you, even on Linux. That's why it's a little confusing. Glad you have a solution.
Have you read the Documentation Contribution Guidelines?
Description
I'm finding Wails v2 is fantastic for my app versus my previous approach of using systray, WebView2 with CGO. Wails is just so much easier and more reliable.
I primarily develop on Linux and then cross-compile for Windows and Darwin. Doing the Windows part entirely from Linux is a big help.
My app still has a requirement for some console utilities. e.g. a daemon and non-graphical environments. Go does a good a good job of that itself.
Do you have any further documentation of how you managed to get all the Windows resources integrated from the Linux host? Any assistance there would be very helpful.
Thanks
Self-service