Minimalist GNU for Windows on Linux

Compiling MinGW gcc 4.9.2 on Ubuntu Trusty 14.04

As I game developer who chose Linux based system as his workstation I would like to have easy possibility to cross compile my games targetting windows architecture. SFML - library which I am using is available for windows in MinGW compiled flavor here http://www.sfml-dev.org/download/sfml/2.3/, but expecting specific version of gcc/g++ - 4.9.2. Unfortunately, at this moment Ubuntu Trusty has packages only for 4.8.2. I managed to backport 4.9.2 package from Ubuntu Wily 15.10, but this is a temporary solution - I plan update soon to Ubuntu Xenial 16.04 which has too new version already :) http://packages.ubuntu.com/xenial/g++-mingw-w64 5.3.1, so after update I would face exactly same probleme - but more difficult - I would need to downgrade original packages, which sounds like a very bad idea.

Compiling with incorrect version of MinGW will lead you to personality error:

The procedure entry point _gxx_persopnality _v0

So, first download the sources from here: https://sourceforge.net/projects/mingw-w64/files/Toolchain%20sources/Personal%20Builds/mingw-builds/4.9.2/, install few packages and you are ready to compilation:

wget http://downloads.sourceforge.net/project/mingw-w64/Toolchain%20sources/Personal%20Builds/mingw-builds/4.9.2/src-4.9.2-release-rt_v4-rev4.tar.7z
sudo apt-get install g++-multilib gcc-multilib
wget http://mirrors.kernel.org/ubuntu/pool/main/g/gmp/libgmpxx4ldbl_6.0.0+dfsg-6ubuntu1_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/main/g/gmp/libgmp-dev_6.0.0+dfsg-6ubuntu1_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/main/g/gmp/libgmp10_6.0.0+dfsg-6ubuntu1_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/main/g/gmp/libgmp3-dev_6.0.0+dfsg-6ubuntu1_amd64.deb
sudo dpkg -i libgmp10_6.0.0+dfsg-6ubuntu1_amd64.deb libgmp3-dev_6.0.0+dfsg-6ubuntu1_amd64.deb libgmp-dev_6.0.0+dfsg-6ubuntu1_amd64.deb libgmpxx4ldbl_6.0.0+dfsg-6ubuntu1_amd64.deb
7z x src-4.9.2-release-rt_v4-rev4.tar.7z
tar xvf src-4.9.2-release-rt_v4-rev4
cd src
./configure --enable-languages=c,c++ --prefix ~/opt/mingw32-gcc-4.9.2
make -j 8 # AMMOUNT_OF_YOUR_CPU * 1.5
make install

Download: precompiled MinGW with gcc / g++ for Ubuntu 14.04.