cross-compiler toolchain using MSVCRT as default runtime.
Default target: i586-w64-mingw32. Optional overlay: i686-w64-mingw32.
Ideal for compiling binaries compatible with Windows 95/98/ME, 2000, XP and other old systems, avoiding UCRT, while allowing SSE2 and AVX for modern CPUs when desired.
Build a clean and minimalist MinGW32 toolchain with:
- binutils
- gcc (phase 1)
- mingw-w64 headers
- mingw-w64 CRT (with MSVCRT)
- gcc (phase 2 - according to mingw32 to make Toolchains or Canadian Cross, is necessary to make GCC in two phases)
- mingw-w64 tools (gendef, genidl, genpeimg, widl)
Supports:
- Legacy Windows (95/98/ME/NT4/2000/XP)
- Modern CPU features (SSE2, AVX) for newer systems, selectable per-project.
- Linux with:
wget,tar,make,gcc,gawk,bison,flex,texinfo- Isolated environment (
chroot,container, etc) recommended - Permissions to install in
/opt(or adjust thePREFIXvariable)
prepare a CHROOT development environment so that your new toolchain does not have problems with your current environment (which probably already has a toolchain) as this can cause problems, to make a clean toolchain, you MUST create a clean development environment in CHROOT or Docker (if you know how to create one)
Below are brief instructions for creating a CHROOT environment in Arch Linux, but this can be reproduced in any distro of your choice, just create the CHROOT according to your distro
1 - install the devtools package (if it is not already installed)
sudo pacman -S devtools2 - Create the CHROOT directory wherever you want (I recommend it to be in the HOME folder)
mkdir -p ~/chroot/mingw-root3 - Create the clean environment in CHROOT (the command will already install the base tools and git inside the CHROOT, include something if necessary) (if you wish)
sudo mkarchroot ~/chroot/mingw-root/root base-devel git4 - Enter your new isolated environment
sudo arch-nspawn ~/chroot/mingw-root/root5 - Inside the CHROOT install the extra dependencies
pacman -Syu --noconfirm \
gcc binutils gmp mpfr mpc zlib isl git \
mingw-w64-headers mingw-w64-crt \
make autoconf automake texinfo6 - Clone this repository
git clone https://github.com/LuizRafael79/mingw32-msvcrtprepare and execute compile-mingw.sh with:
chmod +x compile-mingw.sh
./compile-mingw.shAdd to PATH:
export PATH=$PREFIX/bin:$PATH
edit accordingly your PREFIX configurationi586-w64-mingw32-gcc main.c -o main.exei586-w64-mingw32-gcc main.c -o main.exe -DWINVER=0x500 -D_WIN32_WINNT=0x500i586-w64-mingw32-gcc main.c -o main.exe -DWINVER=0x501 -D_WIN32_WINNT=0x501i586-w64-mingw32-gcc main.c -o main.exe -msse2 -mfpmath=sse(Will not run on 9x/NT4-era hardware.)
i586-w64-mingw32-gcc main.c -o main.exe -mavxAVX needs an OS that saves/restores YMM state. Windows XP does not; think Windows 7 SP1+.
i586-w64-mingw32-g++ main.cpp -o main.exe -static-libgcc -static-libstd++i686-w64-mingw32-gcc main.c -o main.exeUses --with-arch=pentiumpro internally for i686 optimizations
Example with Legacy flags:
i586-w64-mingw32-gcc -nostdlib -static-libgcc -lmingw32 hello.c -o hello.exe- Generate code for Windows 95/98/ME/2k/XP
- Compatible with Windows NT4/2000/XP
- Don't Work with UCRT (but you have to test it)
- Works with MSVCRT (tested)
This project only automates compilations of GNU tools under their respective licenses (GPL/LGPL/BSD).
This repository is part of a complex project comming soon early
| Target Windows | Compiler Flag | CPU Features | Notes |
|---|---|---|---|
| Windows 95/98/ME | i586-w64-mingw32-gcc |
Pentium / MMX | Legacy safe |
| Windows NT4/2000 | -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 |
SSE optional | Modern CPUs can enable SSE2 |
| Windows XP | -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 |
SSE2 default | Works on most XP-era CPUs |
| Windows 7+ | -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 |
SSE2 / AVX optional | Enable AVX with -mavx |
| Modern CPUs | -msse2 -mavx |
SSE2 / AVX | Only for CPUs that support it, may break legacy Windows |
- A Canadian Cross that generate Win32 Mingw32 with these options and...
- A Canadian Cross that the same for... MacOS (yeah, virtually impossible but...)
- Update average use of AVX/AVX2/SSE2/3/4 for Windows 9x/NT/2K/XP for use with Kernel mods and others hacks