What is the MinGW-w64 Toolchain?

#### Gaming Linux® From Scratch - Version 13.0

### Chapter 20. The MinGW-w64 Toolchain

- Prev

  The MinGW-w64 Toolchain

- Next

  MinGW-w64-headers-13.0.0

- Up
- Home

# What is the MinGW-w64 Toolchain?

MinGW-w64 itself is a package providing headers, C runtime libraries, and much more. When support for it is built into compilers such as GCC, it enables the building of software targeting Windows, such as programs and libraries. This software is aimed to be used on Windows, but can also be used on Linux.

### Note

LLVM can also be used for the toolchain. This book will use GCC instead as it has easier instructions, quicker build times, and saves disk space.

Wine-11.2 depends on this functionality to build DLLs (Dynamic Link Libraries), or the equivalent of Linux dynamic libraries, appended with the suffix `.so`, or Shared Objects.

Most Windows software is dynamically linked. While most of them when shipped include DLLs packaged in the installed directory, or extracted from a ZIP file, not all DLLs will be packaged. A number of the dependencies will be installed on a given Windows machine already, such as libraries for DirectX/Direct3D or OpenGL support. Since we are on a Unix-like operating system, we do not have such DLLs installed on the system, and they were never compiled in LFS or earlier in this book. NVIDIA does install DLL files but are strictly meant for Wine and Proton as a way of exposing DLSS. MinGW-w64 only installs static libraries, which are helpful when compiling Windows software, but are useless at runtime. Wine needs to compile the dynamic libraries for most Windows software to function.

If you are a developer and wish to target Windows, this toolchain should be pretty useful. You won't need to follow any of the chapters after this one if you just want the MinGW-w64 toolchain. It is recommended to still install Wine for sanity checks revolving around your built software you are developing, although it isn't a perfect replacement for an accurate Windows environment. While the built software may work fine with Wine, it could be totally broken on Windows.

The following process works up to building the pieces (Windows headers and binutils for linking and assembling Windows software) for a static compilation of GCC, which means it cannot do much of anything with dynamic libraries besides build them. This is especially a problem with C++ software as you need `libstdc++`, which should be dynamic, for linking and execution. This is also a problem for software that uses atomic. Most of all, Windows software built with the toolchain needs `libgcc_s_seh` which is not provided in the static build.

However, this barebones basic toolchain is enough to build up the remaining pieces of the toolchain. After doing so, you can rebuild GCC and have a complete toolchain ready for targeting Windows. Realistically, you could grab a binary distribution of the toolchain and compile everything with less steps. In the past, that is exactly what this book has done. GLFS editors/contributors since then have decided to scrap that idea [11] and have chosen to bootstrap the toolchain instead.

[11] See this issue for rationale behind bootstrapping the MinGW-w64 toolchain. The issue originates from the old Github repository the GLFS project was once hosted.

- Prev

  The MinGW-w64 Toolchain

- Next

  MinGW-w64-headers-13.0.0

- Up
- Home