TL;DR: I managed to successfully build the MinGW-w64 toolchain in my Solus machine. You have an installation script at the end of the post.
I'm really excited about this, and probably You, DXVK compiling try-hard, Wine developer, Proton gamer, etc. After trial and error I've came with the workaround:
First things first get the source codes of stable versions of GCC-binutils, GCC and MinGW-w64 itself (You can clone the repositories locally).
Secondly We could proceed to the installation guide of MinGW-w64, but stick with me please. The thing I've done is building with support of multilib and WITH A DIFFERENT SYSROOT (/opt/mingw-solus).
Lastly I've ran "Hello, World!" tests (in Wine) to make sure things were right.
#include <stdio.h>
int main() {
printf("Hello, World!\n");
}
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
}
Now I'll tell ya some things I've noticed along the way. I've needed to link libstdc++
and libgcc
statically while building the C++ binary (x86_64-w64-mingw32-g++ hello.cpp -o hellocpp.exe -static-libstdc++ -static-libgcc
). When I tried to compile a Rust Language program targeting Windows 32/64bits, horrible errors showed up in my cargo build
output, but I've solved this by coping crt.o
inside the host's i686/x86_64-pc-windows-gnu toolchain directory:
cd <YOUR_RUSTUP_PARENT_FOLDER>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib
mv crt2.o crt2.o.bak
cp <YOUR_MINGW_SYSROOT>/x86_64-w64-mingw32/lib32/crt2.o ./
Here is the beautiful script You can review, try and modify (WARRANTY NOT INCLUDED).