I've been working on a C console project and I've been careful to stick to the standard to ensure some sort of cross-platform compatibility.
Now my question is how to generate an .exe file from the terminal of my Mac OS. So far I have met this task by compiling for my platform using GCC, but it's time to test it on Windows and I have no idea how to accomplish this task.
I have investigated a bit and I have found something about MINGW, I have seen how from package managers of other OS derived from linux they obtain said compiler package, but when searching from mine I only find mingw-w64-binutils that I am not sure of how it works and if it is really what I need.
Cross Compiling
If it is possible to do something similar to cross compilation from OSX to Windows.
Although I could not assure you that it will be fully functional (because there are Windows-only libraries such as conio.h ), but anyway, here I show you what has worked for me to do this type of operation.
1) We download our compiler.
Obviously, as you have mentioned, we must use the MinGW compiler , even though this is the version for OSX.
You can download it here
2) We carry out the installation.
Here it goes without saying that the trick is to click Next, Next :) PS: Yes, my computer is in French.
3) Let's compile!!
Our cross compiler can be found in the following directory:
There we find our compiler, here is the complete path...For
gcc
, if you want to use another one, in the same bin/ directory they can be found.Before continuing, I leave here the source code with which we will do the process:
hello.c
We compile our program:
If we try to run it on OSX, this will appear...
oh! But on Windows...
Here we can show a bit of the cross compilation between OSX and Windows, I hope it works as you expect.