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

c++, freeglut, gcc, glut, opengl

Solution

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 `x86_64-w64-mingw32-gcc-win32`, for example.

Ubuntu, for example, has MinGW in its repositories:

$ apt-cache search mingw
[...]
g++-mingw-w64 - GNU C++ compiler for MinGW-w64
gcc-mingw-w64 - GNU C compiler for MinGW-w64
mingw-w64 - Development environment targeting 32- and 64-bit Windows
[...]

Problem

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 :)

Original source

Related problems