Skip to content

Ubuntu / Debian

Installation

Install the 64bit C and C++ cross-compilers.

$ sudo apt install g++-mingw-w64-x86-64 gcc-mingw-w64-x86-64

To check the version of the provided GCC and mingw-w64 via:

$ apt-cache show gcc-mingw-w64-x86-64 | grep Version:
Version: 13.2.0-6ubuntu1+26.1  # GCC Version
$ apt-cache show mingw-w64-x86-64-dev | grep Version:
Version: 12.0.0-3  # mingw-w64 Version

Building

Cross compiling a Windows executable:

// hello.c
#include <stdio.h>

int main(void) {
    printf("Hello, Windows!\n");
    return 0;
}
$ x86_64-w64-mingw32-gcc hello.c -o hello.exe

Testing

Testing on Linux using Wine:

$ sudo apt install wine
$ wine hello.exe
Hello, Windows!