aboutsummaryrefslogtreecommitdiff
# A minimal MinGW distro ## Downloads The latest version is [2021-08-17]($ROOT/files/mingw-2021-08-17.7z). You can find all downloads from [here]($ROOT/files). ## Components - GCC 11.2.0 - mingw-w64 9.0.0 - binutils 2.36.1 - gdb 10.2 ## Installation Extract the archive to a location of your choosing and put the `bin` directory to your `PATH` ## Updating Remove the contents of the old directory and extract the new version in its place. Don't extract on top of an older version without removing the contents of the old version. ## Installing libraries I recommend using [vcpkg](https://github.com/microsoft/vcpkg) with this toolchain. A simple example how to install zlib: ```powershell > git clone https://github.com/microsoft/vcpkg.git > cd vcpkg > .\bootstrap-vcpkg.bat > $env:Path += ";C:\Path\To\MinGW\bin" > vcpkg install --triplet=x64-mingw-dynamic zlib ``` ## Build requirements On Debian-based systems you can install the requirements with ```sh $ sudo apt install autoconf unzip texinfo wget build-essential ``` You do not need a cross-compiler, as the script will build its own. A native compiler is enough. ## Building As said above, the script will first build a cross-compiler which is then used to build the actual resulting compiler. You can build the compiler on Linux or you can also use Windows Subsystem for Linux (WSL2 is what I use). To build, just execute the build script: ```sh $ ./build.sh ``` If you want to modify where the files are located, just modify the script. The variables used: - `X_ROOT` the root directory under which everything happens, by default `/tmp/mingw` - `X_DOWNLOADS` where to cache downloads, by default `$X_ROOT/downloads` - `X_BUILD` where to extract sources and create build directories, by default `$X_ROOT/build` - `X_DEST` where to install the resulting compiler, by default `$X_ROOT/dest` - `X_CROSS` where to install the cross-compiler, by default `$X_ROOT/cross` By default `make` is instructed to use all CPUs. You can change this by editing the `X_MAKE_OPTS` variable. ## References Some inspiration is taken from Stephan T. Lavavej's MinGW distro (https://nuwen.net/mingw.html). crosstools-ng was used as learning point (https://crosstool-ng.github.io/). MinGW-w64 Wiki contains instructions how to build cross compiler and native compiler (https://sourceforge.net/p/mingw-w64/wiki2/Home).