TIL how to build a PC .exe on my Mac, and RUN it on my Mac.

For reasons that are not important (or at least not interesting, or maybe both), tonight I was researching to see if I could build a PC .exe on a Mac. I asked Copilot, and it suggested I install the “MinGW” cross compiler tools.

Installing MinGW cross compiling tools on a Mac

Using brew, I typed:

brew install mingw-w64

Now that it was installed, to build a simple “hello world” program, I could start with this:

#include <stdio.h>

int main(void)
{
puts ("Hello, world!\");
return 0;
}

And from the directory where that file is located, I can type:

x86_64-w64-mingw32-gcc helloworld.c -o helloworld.exe

And thus…

allenh@Mac HelloWorldPC % ls
helloworld.c helloworld.exe

Neat. This might let me toy with some C source code to figure something out for work without having to get on my PC or run Windows on my Mac.

Then I wondered: could I run it?

Copilot said I could, if I had wine. That sounds like a great idea, but I was sure the AI was confused.

Wine Is Not Emulation

To install Wine, I needed to type this:

brew install --cask wine-stable

Away it went, but I noticed it told me (on my non-Intel Mac) that this would also require Rosetta 2, which is Apple’s Intel emulation layer they used early on when transitioning Macs from Intel to ARM processors. To get that, I did:

softwareupdate --install-rosetta --agree-to-license 

Well, that took no time at all, especially compared to how long MinGW and Wine took to install.

So what now?

Run, EXE! Run!

wine helloworld.exe

…though that did not get me too far, because security.

A quick visit to System Settings and Privacy & Security let me go here and throw caution to the wind…

Well, why not Open Anyway… A few clicks later and…

I’m bored. Let’s go ride bikes.

But first… I tried “winehello world.exe” again (though I had to change back to the directory where it was located).

Sometimes “the juice isn’t worth the squeeze,” and I know I am really late to the wine party, but I thought it was neat.

Until next time…

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.