There are three main versions of the MingW:

1- mingw32-gcc.exe the compiler will build 32-bit applications on 32-bit systems.

2- i686-w64-mingw32-gcc.exe the compiler will build 32-bit applications on 64-bit systems.

3- x86_64-w64-mingw32-gcc.exe the compiler will build 64-bit applications on 64-bit systems.

of course, more details arise once you read the documentation. ensure you are installing the correct version.

Answer from eliahonader on Stack Overflow
🌐
mingw-w64
mingw-w64.org › downloads
Pre-built Toolchains - mingw-w64
LLVM-MinGW is a toolchain built with Clang, LLD, libc++, targeting i686, x86_64, arm and aarch64 (ARM64), with releases both for running as a cross compiler from Linux and for running on Windows. It supports Address Sanitizer, Undefined Behaviour Sanitizer, and generating debug info in PDB format.
🌐
WinLibs
winlibs.com
WinLibs - GCC+MinGW-w64 compiler for Windows
WinLibs - MinGW-w64 personal build = GCC for Windows 32-bit and 64-bit - Coming soon: the largest collection of open source libraries ported to Windows using MinGW-w64 and MSYS2.
🌐
SysTutorials
systutorials.com › docs › linux › man › 1-x86_64-w64-mingw32-gcc
x86_64-w64-mingw32-gcc: GNU project C and C++ compiler - Linux Manuals (1)
Command to display x86_64-w64-mingw32-gcc manual in Linux: $ man 1 x86_64-w64-mingw32-gcc · gcc - GNU project C and C++ compiler · gcc [-c|-S|-E] [-std=standard] [-g] [-pg] [-Olevel] [-Wwarn...] [-Wpedantic] [-Idir...] [-Ldir...] [-Dmacro[=defn]...] [-Umacro] [-foption...] [-mmachine-option...] [-o ·
🌐
GitHub
github.com › avilleret › mingw-w64-build › blob › master › bin › x86_64-w64-mingw32-gcc-4.9.2
mingw-w64-build/bin/x86_64-w64-mingw32-gcc-4.9.2 at master · avilleret/mingw-w64-build
this repo contains mingw-w64 binary build with c++11 thread support - mingw-w64-build/bin/x86_64-w64-mingw32-gcc-4.9.2 at master · avilleret/mingw-w64-build
Author   avilleret
🌐
SourceForge
sourceforge.net › home › open source software › software development › compilers › mingw-w64 - for 32 and 64 bit windows › files
MinGW-w64 - for 32 and 64 bit Windows - Browse /Toolchains targetting Win64/Personal Builds/rubenvb/gcc-4.8-release at SourceForge.net
Packages are named as follows: [Target]-gcc-[Version]-release-[OS]-rubenvb.* [Target]-clang-[Version]-release-[OS]-rubenvb.* Target: GCC triplet for the system this toolchain builds code for: x86_64-w64-mingw32: 64-bit Windows i686-w64-mingw32: 32-bit Windows Version: GCC version OS: OS the ...
🌐
SourceForge
sourceforge.net › home › browse › mingw-w64 - for 32 and 64 bit windows › wiki2
MinGW-w64 - for 32 and 64 bit Windows / Wiki2 / Cross Win32 and Win64 compiler
As of 2009-05-31, x86_64-pc-mingw32 has been replaced by x86_64-w64-mingw32. The change allows for mingw-w64 to have a host/target type independent of mingw.org's MinGW. All default libraries work! We are now in a functional beta stage. This file describes how to build the Mingw-w64 GCC toolchain ...
🌐
Xpack-dev-tools
xpack-dev-tools.github.io › installation guide
Installation Guide | xPack MinGW-w64 GCC
$ ~/.local/xPacks/@xpack-dev-tools/mingw-w64-gcc/15.2.0-2.1/.content/bin/x86_64-w64-mingw32-gcc --version x86_64-w64-mingw32-gcc (xPack MinGW-w64 GCC x86_64) 15.2.0
Find elsewhere
🌐
SourceForge
sourceforge.net › home › browse › mingw-w64 - for 32 and 64 bit windows › wiki2
MinGW-w64 - for 32 and 64 bit Windows / Wiki2 / GeneralUsageInstructions
extract the toolchain to a directory: 32-bit mingw-w32: eg C:\mingw32 so that C:\mingw32\bin contains i686-w64-mingw32-gcc.exe 64-bit mingw-w64: eg C:\mingw64 so that C:\mingw64\bin contains x86_64-w64-mingw32-gcc.exe
🌐
Stack Overflow
stackoverflow.com › questions › 56587400 › linux-to-windows-x86-64-w64-mingw32-gcc-will-not-compile-a-64-bit-executable-h
Linux to Windows: x86_64-w64-mingw32-gcc will not compile a 64-bit executable, how can I resolve this? - Stack Overflow
Also, for the record, the default gcc native to my Debian system works perfectly well with the -m32 and -m64 commands so it's not like my system isn't capable of it and... in fact, if anything, I would expect the behavior to be backwards as Linux seems to require special set-up to do 32-bit builds or run 32-bit programs on a 64-bit machine. For the last attempt to understand the problem myself I ran the command x86_64-w64-mingw32-gcc -v -o hello.exe hello.c hellofunc.c -I .
🌐
mingw-w64
mingw-w64.org
mingw-w64
A complete runtime environment for GCC & LLVM for 32-bit (x86), 64-bit (x64), and ARM64 Windows
🌐
Unvanquished
wiki.unvanquished.net › wiki › MinGW
MinGW - Unvanquished
# 32-bit, sjlj. win32 threads are ... /usr/bin/i686-w64-mingw32-gcc-posix sudo update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix # 64-bit, SEH. win32 threads are selected by default; switch it to posix sudo apt install g++-mingw-w64-x86-64 sudo ...
🌐
Gentoo Wiki
wiki.gentoo.org › wiki › Mingw
MinGW - Gentoo wiki
Most checks in binutils, gdb, gcc, etc (and all their testsuites) are still using mingw32[1]. To install the MinGW toolchain, prepare the system with a crossdev environment: root #emerge --ask app-eselect/eselect-repository sys-devel/crossdev ... We use a target descriptor to tell crossdev what to build: $outputarch-$runtime-mingw32. Throughout this article, the 32-bit toolchain has $outputarch == i686, the 64-bit toolchain has $outputarch == x86_64. Since only MinGW-w64 is used as the runtime, it is assumed $runtime == w64.
🌐
Microsoft Learn
learn.microsoft.com › en-us › vcpkg › users › platforms › mingw
Mingw-w64 | Microsoft Learn
pacman -S --needed git base-devel mingw-w64-x86_64-toolchain · The active subsystem is selected by running the MSYS2 MinGW app, or changed in a running terminal by · source shell mingw64 # for x64, or "mingw32" for x86
🌐
Fedora Discussion
discussion.fedoraproject.org › ask fedora
Location of mingw64/mingw32 system libraries like libgcc_s_seh-1.dll and libwinpthread-1.dll - Fedora Discussion
October 7, 2024 - Everything seems fine except I have difficulties locating system libraries like libgcc_s_seh-1.dll and libwinpthread-1.dll – the resulting executables are linked against them, but I cannot find them. Normally my scripts consult with the compiler, like: x86_64-w64-mingw32-gcc --print-file-name ...
🌐
Debian
wiki.debian.org › Mingw-W64
Mingw-W64 - Debian Wiki
| +- lib | | | +- gcc - (cross-compiler) | | | +-i686-w64-mingw32 | +-x86_64-w64-mingw32 | +- i686-w64-mingw32 - root of x86 toolchain and binaries | | | +- lib - Cross compiler toolchain support libraries / files | | | +- include - Cross compiler toolchain support headers / files | +- ...
🌐
ArchWiki
wiki.archlinux.org › title › MinGW_package_guidelines
MinGW package guidelines - ArchWiki
always add mingw-w64-gcc to makedepends, unless using mingw-w64-configureAUR or mingw-w64-cmakeAUR · always add !strip, staticlibs and !buildflags to options · always use the original pkgdesc and append (mingw-w64) to the end of pkgdesc · always use and follow the original pkgver of the official package · always build both 32-bit and 64-bit versions of libraries · always put all stuff under the /usr/i686-w64-mingw32 and /usr/x86_64-w64-mingw32 prefix
🌐
Stack Overflow
stackoverflow.com › questions › 77039881 › i686-w64-mingw32-gcc-x86-64-w64-mingw32-gcc-not-working-glfw
c - i686-w64-mingw32-gcc/x86_64-w64-mingw32-gcc not working GLFW - Stack Overflow
x86_64-w64-mingw32-gcc -c -o bin/main.o src/main.c $(pkg-config -cflags glfw3) x86_64-w64-mingw32-gcc -o bin/EreecliseWin64.exe src/main.o $(pkg-config --libs glfw3)
🌐
Stack Overflow
stackoverflow.com › questions › 71784463 › compiling-a-c-program-using-x86-64-w64-mingw32-gcc-on-linux
Compiling a C++ program using x86_64-w64-mingw32-gcc on Linux - Stack Overflow
x86_64-w64-mingw32-gcc test.cpp -c test.asm l kernel32 -l user32 -l gdi32 -l winspool -l crypt32 -l comdlg32 -l advapi32 -l shell32 -l ole32 -l oleaut32 -l uuid -l odbc32 -l odbccp32 -I .
Top answer
1 of 3
6

TLDR;
Besides installing a cross target with rustup you need to install an actual cross linker and tell cargo about it using cargo config file or an environment variable

It seems you are attempting to cross compile your package. you can read here more about cross compilation; In a nutshell compiler is a program that takes your text source code and produces something the your operating system and cpu can understand.

When you are building software for the platform you are developing on, it's all nice. You have all the tools but when you want to target another platform or os, you need a compiler that is produced to work on your machine but outputs a binary that is supposed to work on the target platform/os.

So, In your case you need to install a cross toolchain that for mac for mingw target because rust does not have a cross linker itself. Once you get a cross toolchain all you need to do is to tell cargo how to find it.

Here is a project aims to make cross compilation less painful.

I also strongly advise you to read the cargo book here you can see one of the ways of telling cargo about the cross linker another way is to use an environment variable (which I like better and easier to use with makefiles) and below you can see an example of that from one of my makefiles and Again the cargo book refers to it

Overall cross compiling is painful it took me quite some time to understand the mechanics of it but it was worth it instead of copy pasting commands I found on the blogs. I also feel like it lacks severe documentation. Cargo book doesn't tell you anything about finding a linker assumes you know this already and pictures cross compiling as something just work out of box after installing a target toolchain with rustup.

2 of 3
5

For those who work on MacOS (after installing MacPorts) :

sudo port install x86_64-w64-mingw32-gcc

For those who have the same problem on Ubuntu:

sudo apt-get install mingw-w64

This should solve your issue. The cross compiler is not installed by rustup and thus must be installed separately.