-
-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to cross compile from Mac OS to Windows (with answer) #101
Comments
@cgimenez Works like a charm! |
I did not tried but there's an explanation here : https://stackoverflow.com/questions/708238/how-do-i-add-an-icon-to-a-mingw-gcc-compiled-executable Hopefully, the windres utility is available with the mac port's x86_64-w64-mingw32-binutils So, I think you might try to
|
Update here, I got it works! cat > YourExeName.rc << EOL
id ICON "./res/app_win.ico"
GLFW_ICON ICON "./res/app_win.ico"
EOL
x86_64-w64-mingw32-windres YourExeName.rc -O coff -o YourExeName.syso
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ HOST=x86_64-w64-mingw32 go build -ldflags "-s -w -H=windowsgui -extldflags=-static" -p 4 -v -o YourExeName.exe
rm YourExeName.syso
rm YourExeName.rc This script could build Window Executable from MacOS and set app icon and window icon properly. |
Great !! Seems that embedding the .syso file is the go linker's job (I thought would be done by the mingw linker) Found this article about windows manifests files, might be useful to configure further the behaviour of a windows application at runtime : https://xuri.me/2016/06/15/embedded-icon-in-go-windows-application.html |
I've been able to successfully mutate windows programs on macos, but it doesn't work, no error messages, no windows appear. It works fine on macOS. My windows system is windows server 2019 64 bit system `#!/bin/zsh cat > ytfan_gui.rc << EOL x86_64-w64-mingw32-windres ytfan_gui.rc -O coff -o ytfan_gui.syso GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ HOST=x86_64-w64-mingw32 go build -ldflags "-s -w -H=windowsgui -extldflags=-static" -p 4 -v -o ytfan_gui.exe rm ytfan_gui.syso `package main import "github.com/AllenDang/giu" func loop() { func main() { |
Just in case, for people who want to cross compile from Mac OS to Windows. It's not restricted to giu, but might be useful to people using it.
At first I thought It will be a nightmare, but it proved to be very easy, without using https://github.com/karalabe/xgo - so without installing Docker.
My config is :
Under terminal :
sudo port install mingw-w64
Then, you would appreciate to run your app under Wine instead of using a full blown VM. So head to https://www.winehq.org/ - Don't bother trying to install Wine under mac ports, it's a trap, will take forever and a bunch of installed packaged will be "upgraded" to universal versions.
You're done.
Under your giu app directory use
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ HOST=x86_64-w64-mingw32 go build -ldflags "-extldflags=-static" -p 4 -v -o bin/app-amd64.exe
First compilation will take some times to proceed, but subsequent builds will be very fast.
Then
wine bin/app-amd64.exe
Fine. Simple. Efficient. Easy. Coding/Debugging iterations are very fast, it's a breeze !
The text was updated successfully, but these errors were encountered: