I am using Linux/GNU GCC to compile C source code. Is there any way I can generate .exe
files for Windows running on x86 or x64 architecture? The compiled code needs to be generated on the Linux machine.
However, there is thing called MinGW which uses basically the same concepts and includes a minimal GNU runtime so you can easily make programs that compile on a GNU/Linux system and run on Windows. Note, though, that you'll need to compile your code twice — C++ just isn't designed for "write once, run anywhere".
GCC is portable and run in many operating platforms. GCC (and GNU Toolchain) is currently available on all Unixes. They are also ported to Windows (by Cygwin, MinGW and MinGW-W64). GCC is also a cross-compiler, for producing executables on different platform.
You would need a cross-compiler to create a Windows executable in Linux.
Mingw-w64 is an advancement of the original mingw.org project, created to support the GCC compiler on Windows systems.
Installing the cross-compilation
sudo apt-get install mingw-w64
32bit
i686-w64-mingw32-gcc -o test.exe test.c
64bit
x86_64-w64-mingw32-gcc -o test.exe test.c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With