Louise Louise - 2 months ago 13
C++ Question

How to compile for Windows on Linux with gcc/g++?

I have written some effects in C++ (g++) using freeglut on Linux, and I compile them with

g++ -Wall -lglut part8.cpp -o part8


So I was wondering if it is possible to have g++ make static compiled Windows executables that contains everything needed?

I don't have Windows, so it would be really cool, if I could do that on Linux :)

Answer

mingw32 exists as a package for Linux. You can cross-compile and -link Windows applications with it. There's a tutorial here at the Code::Blocks forum. Mind that the command changes to mingw32-gcc, for example.

EDIT: Debian Linux, for example, has MinGW in its repositories:

$ apt-cache search mingw
mingw32 - Minimalist GNU win32 (cross) compiler
mingw32-binutils - Minimalist GNU win32 (cross) binutils
mingw32-runtime - Minimalist GNU win32 (cross) runtime
gcc-mingw32 - The GNU Compiler Collection (cross compiler for MingW32)
...