This is just a revision of my previous post on Cygwin setup with focus on MinGW64. I hope this guide will more or less make it easy to install MinGW64 on Windows. After following this guide, you'll be ready to develop native Windows applications. Just download and run setup.exe from the Cygwin website and choose the following packages.
- bison
- flex
- gettext-devel
- libtool
- make
- mingw64-i686-gcc-g++
- mingw64-x86_64-gcc-g++
- patch
- pkg-config
To select a package for installation, type the name of the package in the Search box, expand the category by clicking the + sign, and click on the package until its version number shows up.
When you see the Resolving Dependencies window, just accept and click Next.
Creating Symbolic Links to GCC and G++
Launch the Cygwin terminal and create symbolic links to gcc and g++ in this manner.
ln -s /usr/bin/i686-w64-mingw32-gcc.exe /usr/i686-w64-mingw32/bin/gcc.exe
ln -s /usr/bin/i686-w64-mingw32-g++.exe /usr/i686-w64-mingw32/bin/g++.exe
ln -s /usr/bin/x86_64-w64-mingw32-gcc.exe /usr/x86_64-w64-mingw32/bin/gcc.exe
ln -s /usr/bin/x86_64-w64-mingw32-g++.exe /usr/x86_64-w64-mingw32/bin/g++.exe
Setting up environment variables
If you're building 32-bit applications, type the following commands or put them in ~/.profile:
export CC=/usr/bin/i686-w64-mingw32-gcc.exe
export CPP=/usr/bin/i686-w64-mingw32-cpp.exe
export CXX=/usr/bin/i686-w64-mingw32-g++.exe
export CFLAGS="-mtune=pentium-mmx -mthreads -mms-bitfields -O2 -static-libgcc"
export CXXFLAGS="-mtune=pentium-mmx -mthreads -mms-bitfields -O2 -static-libstdc++"
export PATH=/mingw/bin:/usr/i686-w64-mingw32/bin:/usr/bin
export PKG_CONFIG_PATH=/mingw/lib/pkgconfig
If you're building 64-bit applications, type the following or put in ~/.profile:
export CC=/usr/bin/x86_64-w64-mingw32-gcc.exe
export CPP=/usr/bin/x86_64-w64-mingw32-cpp.exe
export CXX=/usr/bin/x86_64-w64-mingw32-g++.exe
export CFLAGS="-mtune=core2 -mthreads -mms-bitfields -O2"
export CXXFLAGS="-mtune=core2 -mthreads -mms-bitfields -O2"
export PATH=/mingw/bin:/usr/x86_64-w64-mingw32/bin:/usr/bin
export PKG_CONFIG_PATH=/mingw/lib/pkgconfig
For more information on possible -mtune values, look here.
Create a NTFS junction for /home
You may get a compile-time error when you try to build some software that want to access a file on real Windows path. I often unpack program sources inside /home (actually, C:\cygwin\home), and compile software there. Sometimes, compilation fails if compile-time applets try to access a file in C:\home. In that case, use junction to create a NTFS symbolic link to C:\cygwin\home.
cd \
junction home C:\cygwin\home
Additional Notes
Open-source software typically take the following commands in order to get compiled with MinGW64. In case of the 32-bit compiler, run:
./configure --build=i686-w64-mingw32 --prefix=/usr/i686-w64-mingw32
make
make install
As for the 64-bit compiler, just use a different --build option.
./configure --build=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32
make
make install
Also Read