<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent changes to wiki2</title><link href="https://sourceforge.net/p/mingw-w64/wiki2/" rel="alternate"/><link href="https://sourceforge.net/p/mingw-w64/wiki2/feed.atom" rel="self"/><id>https://sourceforge.net/p/mingw-w64/wiki2/</id><updated>2026-04-03T02:46:54.666000Z</updated><subtitle>Recent changes to wiki2</subtitle><entry><title>Home modified by LIU Hao</title><link href="https://sourceforge.net/p/mingw-w64/wiki2/Home/" rel="alternate"/><published>2026-04-03T02:46:54.666000Z</published><updated>2026-04-03T02:46:54.666000Z</updated><author><name>LIU Hao</name><uri>https://sourceforge.net/u/lhmouse/</uri></author><id>https://sourceforge.net46c4f6d35d951485767bab77c74726528c68126a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v4
+++ v5
@@ -28,7 +28,7 @@

   * [Compilation instructions for Runtime](Compiling%20the%20Runtime)
   * [Information about releases of mingw-w64](Information%20aboutreleases%20of%20mingw-w64)
   * [howto: Building projects with MinGW-W64](Building%20projects%20with%20MinGW-W64)
-  * [howto: Build a native Windows 64-bit gcc from Linux (including cross-compiler)](Build%20a%20native%20Windows%2064-bit%20gcc%20from%20Linux%20%28including%20cross-compiler%29/)
+  * [howto: Build a native Windows 64-bit gcc from Linux (including cross-compiler)](Build%20a%20native%20Windows%2064-bit%20gcc%20from%20Linux%20%28including%20cross-compiler%29)
   * [howto: Running testsuite on Linux via Wine](Running%20the%20testsuite%20on%20Linux)
   * [Versions of software required for building](Versions%20of%20software%20required%20for%20building)
   * [howto: Creating a buildbot slave](Create%20a%20buildbot%20slave)
&lt;/pre&gt;
&lt;/div&gt;</summary></entry><entry><title>Home modified by &lt;REDACTED&gt;</title><link href="https://sourceforge.net/p/mingw-w64/wiki2/Home/" rel="alternate"/><published>2023-02-21T18:04:37.280000Z</published><updated>2023-02-21T18:04:37.280000Z</updated><author><name/><uri>https://sourceforge.net</uri></author><id>https://sourceforge.net51e290d28421fd70e1d1720e7785e6493045095b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -1,6 +1,6 @@
 This is the MinGW-w64 Wiki. 

-For users looking for MinGW-w64 downloads, please see [the download page on the website](http://mingw-w64.sourceforge.net/download.php). 
+For users looking for MinGW-w64 downloads, please see [the download page on the website](https://www.mingw-w64.org/downloads/).

 For users looking for support with a specific issue not detailed on this Wiki: 

&lt;/pre&gt;
&lt;/div&gt;</summary></entry><entry><title>Home modified by &lt;REDACTED&gt;</title><link href="https://sourceforge.net/p/mingw-w64/wiki2/Home/" rel="alternate"/><published>2023-02-21T17:57:54.046000Z</published><updated>2023-02-21T17:57:54.046000Z</updated><author><name/><uri>https://sourceforge.net</uri></author><id>https://sourceforge.net1f9e6850ee5898c8a6c6b3813e29a114e86ce6af</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -28,8 +28,7 @@
   * [Compilation instructions for Runtime](Compiling%20the%20Runtime)
   * [Information about releases of mingw-w64](Information%20aboutreleases%20of%20mingw-w64)
   * [howto: Building projects with MinGW-W64](Building%20projects%20with%20MinGW-W64)
-  * [howto: Creating a cross Win32 and Win64 compiler](Cross%20Win32%20and%20Win64%20compiler)
-  * [howto: Creating a native Win64 compiler](Native%20Win64%20compiler)
+  * [howto: Build a native Windows 64-bit gcc from Linux (including cross-compiler)](Build%20a%20native%20Windows%2064-bit%20gcc%20from%20Linux%20%28including%20cross-compiler%29/)
   * [howto: Running testsuite on Linux via Wine](Running%20the%20testsuite%20on%20Linux)
   * [Versions of software required for building](Versions%20of%20software%20required%20for%20building)
   * [howto: Creating a buildbot slave](Create%20a%20buildbot%20slave)
&lt;/pre&gt;
&lt;/div&gt;</summary></entry><entry><title>Build a native Windows 64-bit gcc from Linux (including cross-compiler) modified by &lt;REDACTED&gt;</title><link href="https://sourceforge.net/p/mingw-w64/wiki2/Build%2520a%2520native%2520Windows%252064-bit%2520gcc%2520from%2520Linux%2520%2528including%2520cross-compiler%2529/" rel="alternate"/><published>2023-02-21T10:20:38.208000Z</published><updated>2023-02-21T10:20:38.208000Z</updated><author><name/><uri>https://sourceforge.net</uri></author><id>https://sourceforge.net0295df80fdf1e4248cddb8f24e2c821e3f047269</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -1,4 +1,4 @@
-This is a guide for building a native Windows 64-bit gcc compiler with mingw-w64 from Linux.
+#How to build a native Windows 64-bit gcc compiler from Linux, including a cross-compiler

 Cross-compiling a native Windows compiler from Linux tends to be a lot faster than building
 it 'natively' on Windows using, say, MSYS2.    It is a bit more complicated though because
@@ -48,9 +48,9 @@
 ### Step 1: Create folder structure ###

 Select a working folder and save it in the START_DIR environment variable:
-
+~~~
 export START_DIR=/my/working/dir
-
+~~~
 cd into it and create the following tree for the entire procedure:

 mingw-builds
@@ -72,6 +72,7 @@
 --------cross
 --------native

+~~~
 mkdir mingw-builds
 cd mingw-builds
 mkdir src build install
@@ -86,7 +87,7 @@
 cd ../../install
 mkdir cross native
 cd ..
-
+~~~



@@ -111,19 +112,19 @@
 Rename or create symbolic links to remove the version and match the names under src/

 Git repositories:
-
+~~~
 cd src

 git clone git://sourceware.org/git/binutils-gdb.git binutils
 git clone https://git.code.sf.net/p/mingw-w64/mingw-w64 mingw-w64
 git clone git://gcc.gnu.org/git/gcc.git gcc
-
+~~~
 Next, download gcc prerequisites using its own script:
-
+~~~
 cd gcc
 contrib/download_prerequisites
 cd ../..
-
+~~~



@@ -132,73 +133,74 @@

 1) Start with cross-binutils, the first component of the cross-compiler, and install in
 the cross-compiler installation folder.
-
+~~~
 cd $START_DIR/mingw-builds/build/cross/binutils
 ../../../src/binutils/configure --prefix=$START_DIR/mingw-builds/install/cross --target=x86_64-w64-mingw32 --disable-multilib
-
+~~~
 Adjust NUM_CORES to your number of cores.
-
+~~~
 export NUM_CORES=12
-
+~~~
+~~~
 make -j$NUM_CORES
 make install
-
+~~~
 2) Add the bin folder of the cross-compiler installation to the path so that subsequent steps can find it.
-
+~~~
 export PATH=$START_DIR/mingw-builds/install/cross/bin:$PATH
-
+~~~
 3) Install the mingw-w64 headers into the target (Windows) sysroot of the cross-compiler.
-
+~~~
 cd $START_DIR/mingw-builds/build/cross/mingw-w64-headers
 ../../../src/mingw-w64/mingw-w64-headers/configure --host=x86_64-w64-mingw32 --prefix=$START_DIR/mingw-builds/install/cross/x86_64-w64-mingw32

 make install
-
+~~~
 4) With the target headers installed, build the core gcc cross-compiler (not a full working cross-compiler yet).
-
+~~~
 cd $START_DIR/mingw-builds/build/cross/gcc
 ../../../src/gcc/configure --prefix=$START_DIR/mingw-builds/install/cross --target=x86_64-w64-mingw32 --disable-multilib --enable-languages=c,c++

 make -j$NUM_CORES all-gcc
 make install-gcc
-
+~~~
 This creates more binaries in install/cross/bin including gcc and g++ (prefixed by target).
 This is gcc core only.    It cannot compile Windows binaries yet.

 5) Build mingw-w64 CRT and install into cross-compiler sysroot.    Note we are using --host here!
-
+~~~
 cd $START_DIR/mingw-builds/build/cross/mingw-w64
 ../../../src/mingw-w64/configure --host=x86_64-w64-mingw32 --prefix=$START_DIR/mingw-builds/install/cross/x86_64-w64-mingw32
-
+~~~
 I have deliberately left out -j$NUM_CORES in this call to make because I have observed race conditions where
 compilation fails due to not being able to find some file when parallelism is used, and the problem goes
 away without parallelism.    Unfortunately, this makes the build slower.
-
+~~~
 make
 make install
-
+~~~
 We now have the mingw-w64 libraries and headers in the cross-compiler sysroot.

 6) Finish building the gcc cross-compiler (combine the already-built core with the just-built mingw-w64 libs).
-
+~~~
 cd $START_DIR/mingw-builds/build/cross/gcc
 make -j$NUM_CORES
 make install
-
+~~~
 This updates (finalizes) the binaries in install/cross/bin and libs in install/cross/lib

 Note these are all Linux binaries, since this is a cross-compiler that runs on Linux (and produces Windows binaries).

 7) Test the newly-built cross-compiler.    It should be already in the path from before.
-
+~~~
 x86_64-w64-mingw32-gcc --version
-
+~~~
 must return whatever source we built it from (currently 13.0.1).

 Compile a dummy Windows program:
-
+~~~
 echo -ne '#include &amp;lt;windows.h&amp;gt;\n#include &amp;lt;stdio.h&amp;gt;\nint main() {printf("Hello\\n"); return 0;}\n' | x86_64-w64-mingw32-gcc -xc -
-
+~~~
 Run the output binary through the 'file' command to see that it's a Windows binary, or even copy it to a network path
 that is also accessible from a Windows machine and run it.

@@ -214,23 +216,23 @@
 cross-compiled because the --build option is a Linux one (guessed).

 1) Build Windows-native binutils.
-
+~~~
 cd $START_DIR/mingw-builds/build/native/binutils
 ../../../src/binutils/configure --prefix=$START_DIR/mingw-builds/install/native --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-multilib

 make -j$NUM_CORES
 make install
-
+~~~
 This creates Windows .exe binaries in install/native/bin and other folders under install/native

 2) Build Windows-native gcc.
-
+~~~
 cd $START_DIR/mingw-builds/build/native/gcc
 ../../../src/gcc/configure --prefix=$START_DIR/mingw-builds/install/native --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-multilib --enable-languages=c,c++

 make -j$NUM_CORES
 make install
-
+~~~
 This installs the Windows .exe binaries in install/native/bin including gcc.exe and g++.exe
 They don't have the target prefix any more as they are native Windows programs that don't run on Linux.

@@ -238,8 +240,12 @@
 don't find it in bin, which has to be in the path anyway.

 Therefore just move it from lib to bin at this point (the gcc configure option --with-slibdir didn't do it):
-
+~~~
 mv $START_DIR/mingw-builds/install/native/lib/libgcc_s_seh-1.dll $START_DIR/mingw-builds/install/native/bin/
+~~~
+
+An alternative would be to add lib to the Windows path as well, in which case the file doesn't have
+to be moved under bin.

 The new Windows-native gcc is almost ready.    It doesn't make sense to add this to the Linux path since it
 is not a host (Linux) tool anyway.
@@ -250,37 +256,39 @@
 cross-compiled binutils.    It should also get the mingw-w64 headers and libs.

 3) Build mingw-w64 headers and libs (including winpthreads) and install into native toolchain sysroot.
-
+~~~
 cd $START_DIR/mingw-builds/build/native/mingw-w64
 ../../../src/mingw-w64/configure --host=x86_64-w64-mingw32 --prefix=$START_DIR/mingw-builds/install/native/x86_64-w64-mingw32 --with-libraries=winpthreads
-
+~~~
 Note: Unlike when we were building the cross-compiler, we don't have to install the mingw-w64 headers separately first.
 Note: Again, deliberately leaving out parallelization here.    Try at your own risk.
-
+~~~
 make
 make install
-
+~~~
 This adds libraries and headers in subfolders in the sysroot install/native/x86_64-w64-mingw32

 Note: libwinpthread-1.dll is in the sysroot bin folder, so move it to the toolchain bin folder in order
 for it to be found by Windows running binaries, similar to what we did with libgcc_s_seh-1.dll above:
-
+~~~
 mv $START_DIR/mingw-builds/install/native/x86_64-w64-mingw32/bin/libwinpthread-1.dll $START_DIR/mingw-builds/install/native/bin/
-
+~~~
 The new Windows-native gcc toolchain is now ready.

 4) Package the native installation folder and deploy to Windows.
-
+~~~
 cd $START_DIR/mingw-builds/install
-(consider renaming 'native' do a different name if you want)
+~~~
+Consider renaming 'native' before zipping.
+~~~
 zip -r mingw64.zip native
-
+~~~
 Copy it to a Windows machine, unzip, and use it.

 Suppose it was extracted in C:\native.   Add the bin subfolder to the Windows path:
-
+~~~
 set PATH=C:\native\bin;%PATH%
-
+~~~
 From Command Prompt, 'where gcc' should find gcc.exe

 Compile with gcc a C file that includes windows.h stdio.h pthread.h and uses pthreads (must compile with -pthread flag).
&amp;lt;/stdio.h&amp;gt;&amp;lt;/windows.h&amp;gt;&lt;/pre&gt;
&lt;/div&gt;</summary></entry><entry><title>CrossQuickstart modified by &lt;REDACTED&gt;</title><link href="https://sourceforge.net/p/mingw-w64/wiki2/CrossQuickstart/" rel="alternate"/><published>2023-02-20T23:28:32.834000Z</published><updated>2023-02-20T23:28:32.834000Z</updated><author><name/><uri>https://sourceforge.net</uri></author><id>https://sourceforge.net32d3f5e830acfdcf17199672d0fd28f27b7824ae</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -1,3 +1,4 @@
+# A more recent guide for building a cross-compiler in a Linux environment exists [here](https://sourceforge.net/p/mingw-w64/wiki2/Build%20a%20native%20Windows%2064-bit%20gcc%20from%20Linux%20%28including%20cross-compiler%29/)
 # Cross Compilation Quickstart

 ## The Need for Cross Compilers
&lt;/pre&gt;
&lt;/div&gt;</summary></entry><entry><title>Native Win64 compiler modified by &lt;REDACTED&gt;</title><link href="https://sourceforge.net/p/mingw-w64/wiki2/Native%2520Win64%2520compiler/" rel="alternate"/><published>2023-02-20T23:26:20.051000Z</published><updated>2023-02-20T23:26:20.051000Z</updated><author><name/><uri>https://sourceforge.net</uri></author><id>https://sourceforge.net744d6b4c0bd9b34dce02cbee5c5dd30f147fa7a8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -1,3 +1,4 @@
+## A more recent guide for building a native Win64 compiler in a Linux environment exists [here](https://sourceforge.net/p/mingw-w64/wiki2/Build%20a%20native%20Windows%2064-bit%20gcc%20from%20Linux%20%28including%20cross-compiler%29/)
 # Creating a native Win64 compiler

 To create a native Windows x86-64 compiler you first have to create a MinGW-w64 cross compiler. 
&lt;/pre&gt;
&lt;/div&gt;</summary></entry><entry><title>Cross Win32 and Win64 compiler modified by &lt;REDACTED&gt;</title><link href="https://sourceforge.net/p/mingw-w64/wiki2/Cross%2520Win32%2520and%2520Win64%2520compiler/" rel="alternate"/><published>2023-02-20T23:24:28.423000Z</published><updated>2023-02-20T23:24:28.423000Z</updated><author><name/><uri>https://sourceforge.net</uri></author><id>https://sourceforge.net7c1e11b14c7705b8e7645c7e3462104ff9c125f4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -1,3 +1,4 @@
+## A more recent guide for building a cross-compiler in a Linux environment exists [here](https://sourceforge.net/p/mingw-w64/wiki2/Build%20a%20native%20Windows%2064-bit%20gcc%20from%20Linux%20%28including%20cross-compiler%29/)
 How to build a Mingw-w64 x86_64-w64-mingw32 cross-compiler. 

 ## About this document
&lt;/pre&gt;
&lt;/div&gt;</summary></entry><entry><title>Build a native Windows 64-bit gcc from Linux (including cross-compiler) modified by &lt;REDACTED&gt;</title><link href="https://sourceforge.net/p/mingw-w64/wiki2/Build%2520a%2520native%2520Windows%252064-bit%2520gcc%2520from%2520Linux%2520%2528including%2520cross-compiler%2529/" rel="alternate"/><published>2023-02-20T23:11:21.555000Z</published><updated>2023-02-20T23:11:21.555000Z</updated><author><name/><uri>https://sourceforge.net</uri></author><id>https://sourceforge.netc7a4fb6ba620eb5b634d5a1cc5c66f3ddfa2bdca</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -54,23 +54,23 @@
 cd into it and create the following tree for the entire procedure:

 mingw-builds
-   src
-       binutils
-       mingw-w64
-       gcc
-   build
-       cross
-           binutils
-           mingw-w64-headers
-           mingw-w64
-           gcc
-       native
-           binutils
-           mingw-w64
-           gcc
-   install
-       cross
-       native
+----src
+--------binutils
+--------mingw-w64
+--------gcc
+----build
+--------cross
+------------binutils
+------------mingw-w64-headers
+------------mingw-w64
+------------gcc
+--------native
+------------binutils
+------------mingw-w64
+------------gcc
+----install
+--------cross
+--------native

 mkdir mingw-builds
 cd mingw-builds
&lt;/pre&gt;
&lt;/div&gt;</summary></entry><entry><title>Build a native Windows 64-bit gcc from Linux (including cross-compiler) modified by &lt;REDACTED&gt;</title><link href="https://sourceforge.net/p/mingw-w64/wiki2/Build%2520a%2520native%2520Windows%252064-bit%2520gcc%2520from%2520Linux%2520%2528including%2520cross-compiler%2529/" rel="alternate"/><published>2023-02-20T22:48:59.811000Z</published><updated>2023-02-20T22:48:59.811000Z</updated><author><name/><uri>https://sourceforge.net</uri></author><id>https://sourceforge.neta7f6951352db4c127f5e398afacc0c2fb586ce1e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;This is a guide for building a native Windows 64-bit gcc compiler with mingw-w64 from Linux.&lt;/p&gt;
&lt;p&gt;Cross-compiling a native Windows compiler from Linux tends to be a lot faster than building&lt;br/&gt;
it 'natively' on Windows using, say, MSYS2.    It is a bit more complicated though because&lt;br/&gt;
one first has to build a Linux-to-Windows cross-compiler from the same sources and then use&lt;br/&gt;
it to cross-compile the native Windows compiler.    Then, the native Windows gcc + mingw-w64&lt;br/&gt;
can be deployed to a Windows system to build native Windows programs.&lt;/p&gt;
&lt;p&gt;Everything is compiled from source, which allows using the latest versions of gcc, mingw-w64&lt;br/&gt;
and binutils.&lt;/p&gt;
&lt;p&gt;In this guide, the build system used was Debian GNU/Linux 11 (bullseye) and the system gcc&lt;br/&gt;
version was 10.2.1 (currently latest in Debian repo).    The machine was a standard x86_64.&lt;/p&gt;
&lt;p&gt;From a high-level, there are four steps:&lt;/p&gt;
&lt;p&gt;1) Cd into a working folder of your choice and create the full folder structure that will&lt;br/&gt;
contain the sources, build and installation folders for the cross-compiler and native&lt;br/&gt;
Windows compiler.&lt;/p&gt;
&lt;p&gt;2) Get the sources in the src folder.    This can be done by downloading source tarballs,&lt;br/&gt;
using 'git clone', or any other way to get the source code for binutils, mingw-w64 and gcc.&lt;br/&gt;
The versions used in this guide were:&lt;/p&gt;
&lt;p&gt;binutils-2.40&lt;br/&gt;
mingw-w64-v10.0.0&lt;br/&gt;
gcc-13.0.1 (experimental, git clone'd)&lt;/p&gt;
&lt;p&gt;3) Natively-compile a cross-compiler.    The Debian system gcc is used to build the gcc&lt;br/&gt;
cross-compiler that targets x86_64-w64-mingw32 using mingw-w64.   Strictly speaking, this&lt;br/&gt;
step is not necessary because one can always obtain the cross-compiler as a package from&lt;br/&gt;
their distro, but, if the version is not recent enough, the cross-compiler might fail to&lt;br/&gt;
build the native Windows compiler from the latest gcc sources:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100341" rel="nofollow"&gt;https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100341&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Building the cross-compiler itself ensures that the same gcc sources are used for both&lt;br/&gt;
compilers, avoiding such issues.&lt;/p&gt;
&lt;p&gt;4) Cross-compile a native (Windows) compiler.    The cross-compiler we built in step #3&lt;br/&gt;
will be used to build a native 64-bit Windows gcc, which is ready to be deployed in a&lt;br/&gt;
Windows system and build native Windows programs using the latest gcc features.&lt;/p&gt;
&lt;h3 id="step-1-create-folder-structure"&gt;Step 1: Create folder structure&lt;/h3&gt;
&lt;p&gt;Select a working folder and save it in the START_DIR environment variable:&lt;/p&gt;
&lt;p&gt;export START_DIR=/my/working/dir&lt;/p&gt;
&lt;p&gt;cd into it and create the following tree for the entire procedure:&lt;/p&gt;
&lt;p&gt;mingw-builds&lt;br/&gt;
    src&lt;br/&gt;
        binutils&lt;br/&gt;
        mingw-w64&lt;br/&gt;
        gcc&lt;br/&gt;
    build&lt;br/&gt;
        cross&lt;br/&gt;
            binutils&lt;br/&gt;
            mingw-w64-headers&lt;br/&gt;
            mingw-w64&lt;br/&gt;
            gcc&lt;br/&gt;
        native&lt;br/&gt;
            binutils&lt;br/&gt;
            mingw-w64&lt;br/&gt;
            gcc&lt;br/&gt;
    install&lt;br/&gt;
        cross&lt;br/&gt;
        native&lt;/p&gt;
&lt;p&gt;mkdir mingw-builds&lt;br/&gt;
cd mingw-builds&lt;br/&gt;
mkdir src build install&lt;br/&gt;
cd src&lt;br/&gt;
mkdir binutils mingw-w64 gcc&lt;br/&gt;
cd ../build&lt;br/&gt;
mkdir cross native&lt;br/&gt;
cd cross&lt;br/&gt;
mkdir binutils mingw-w64-headers mingw-w64 gcc&lt;br/&gt;
cd ../native&lt;br/&gt;
mkdir binutils mingw-w64 gcc&lt;br/&gt;
cd ../../install&lt;br/&gt;
mkdir cross native&lt;br/&gt;
cd ..&lt;/p&gt;
&lt;h3 id="step-2-get-sources"&gt;Step 2: Get sources&lt;/h3&gt;
&lt;p&gt;Download sources into the corresponding folder under mingw-builds/src/&lt;br/&gt;
This can be a 'git clone' command, a 'wget' download, or any other means to get the sources&lt;br/&gt;
as long as they end up in their designated folder.    The 'configure' script for each&lt;br/&gt;
project must be in the corresponding subfolder under mingw-builds/src/&lt;/p&gt;
&lt;p&gt;For convenience, here are the links for obtaining tarballs or git repositories for the&lt;br/&gt;
three projects.&lt;/p&gt;
&lt;p&gt;Source code tarballs sorted with most recent version first:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://ftp.gnu.org/gnu/binutils/?C=M;O=D" rel="nofollow"&gt;https://ftp.gnu.org/gnu/binutils/?C=M;O=D&lt;/a&gt;&lt;br/&gt;
&lt;a href="https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/"&gt;https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/&lt;/a&gt;&lt;br/&gt;
&lt;a href="https://ftp.gnu.org/gnu/gcc/?C=M;O=D" rel="nofollow"&gt;https://ftp.gnu.org/gnu/gcc/?C=M;O=D&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Note that when extracting the tarballs the resulting folder name will have the version.&lt;br/&gt;
Rename or create symbolic links to remove the version and match the names under src/&lt;/p&gt;
&lt;p&gt;Git repositories:&lt;/p&gt;
&lt;p&gt;cd src&lt;/p&gt;
&lt;p&gt;git clone git://sourceware.org/git/binutils-gdb.git binutils&lt;br/&gt;
git clone &lt;a href="https://git.code.sf.net/p/mingw-w64/mingw-w64" rel="nofollow"&gt;https://git.code.sf.net/p/mingw-w64/mingw-w64&lt;/a&gt; mingw-w64&lt;br/&gt;
git clone git://gcc.gnu.org/git/gcc.git gcc&lt;/p&gt;
&lt;p&gt;Next, download gcc prerequisites using its own script:&lt;/p&gt;
&lt;p&gt;cd gcc&lt;br/&gt;
contrib/download_prerequisites&lt;br/&gt;
cd ../..&lt;/p&gt;
&lt;h3 id="step-3-build-with-system-gcc-a-linux-hosted-cross-compiler-that-targets-x86_64-w64-mingw32"&gt;Step 3: Build (with system gcc) a Linux-hosted cross-compiler that targets x86_64-w64-mingw32&lt;/h3&gt;
&lt;p&gt;1) Start with cross-binutils, the first component of the cross-compiler, and install in&lt;br/&gt;
the cross-compiler installation folder.&lt;/p&gt;
&lt;p&gt;cd $START_DIR/mingw-builds/build/cross/binutils&lt;br/&gt;
../../../src/binutils/configure --prefix=$START_DIR/mingw-builds/install/cross --target=x86_64-w64-mingw32 --disable-multilib&lt;/p&gt;
&lt;p&gt;Adjust NUM_CORES to your number of cores.&lt;/p&gt;
&lt;p&gt;export NUM_CORES=12&lt;/p&gt;
&lt;p&gt;make -j$NUM_CORES&lt;br/&gt;
make install&lt;/p&gt;
&lt;p&gt;2) Add the bin folder of the cross-compiler installation to the path so that subsequent steps can find it.&lt;/p&gt;
&lt;p&gt;export PATH=$START_DIR/mingw-builds/install/cross/bin:$PATH&lt;/p&gt;
&lt;p&gt;3) Install the mingw-w64 headers into the target (Windows) sysroot of the cross-compiler.&lt;/p&gt;
&lt;p&gt;cd $START_DIR/mingw-builds/build/cross/mingw-w64-headers&lt;br/&gt;
../../../src/mingw-w64/mingw-w64-headers/configure --host=x86_64-w64-mingw32 --prefix=$START_DIR/mingw-builds/install/cross/x86_64-w64-mingw32&lt;/p&gt;
&lt;p&gt;make install&lt;/p&gt;
&lt;p&gt;4) With the target headers installed, build the core gcc cross-compiler (not a full working cross-compiler yet).&lt;/p&gt;
&lt;p&gt;cd $START_DIR/mingw-builds/build/cross/gcc&lt;br/&gt;
../../../src/gcc/configure --prefix=$START_DIR/mingw-builds/install/cross --target=x86_64-w64-mingw32 --disable-multilib --enable-languages=c,c++&lt;/p&gt;
&lt;p&gt;make -j$NUM_CORES all-gcc&lt;br/&gt;
make install-gcc&lt;/p&gt;
&lt;p&gt;This creates more binaries in install/cross/bin including gcc and g++ (prefixed by target).&lt;br/&gt;
This is gcc core only.    It cannot compile Windows binaries yet.&lt;/p&gt;
&lt;p&gt;5) Build mingw-w64 CRT and install into cross-compiler sysroot.    Note we are using --host here!&lt;/p&gt;
&lt;p&gt;cd $START_DIR/mingw-builds/build/cross/mingw-w64&lt;br/&gt;
../../../src/mingw-w64/configure --host=x86_64-w64-mingw32 --prefix=$START_DIR/mingw-builds/install/cross/x86_64-w64-mingw32&lt;/p&gt;
&lt;p&gt;I have deliberately left out -j$NUM_CORES in this call to make because I have observed race conditions where&lt;br/&gt;
compilation fails due to not being able to find some file when parallelism is used, and the problem goes&lt;br/&gt;
away without parallelism.    Unfortunately, this makes the build slower.&lt;/p&gt;
&lt;p&gt;make&lt;br/&gt;
make install&lt;/p&gt;
&lt;p&gt;We now have the mingw-w64 libraries and headers in the cross-compiler sysroot.&lt;/p&gt;
&lt;p&gt;6) Finish building the gcc cross-compiler (combine the already-built core with the just-built mingw-w64 libs).&lt;/p&gt;
&lt;p&gt;cd $START_DIR/mingw-builds/build/cross/gcc&lt;br/&gt;
make -j$NUM_CORES&lt;br/&gt;
make install&lt;/p&gt;
&lt;p&gt;This updates (finalizes) the binaries in install/cross/bin and libs in install/cross/lib&lt;/p&gt;
&lt;p&gt;Note these are all Linux binaries, since this is a cross-compiler that runs on Linux (and produces Windows binaries).&lt;/p&gt;
&lt;p&gt;7) Test the newly-built cross-compiler.    It should be already in the path from before.&lt;/p&gt;
&lt;p&gt;x86_64-w64-mingw32-gcc --version&lt;/p&gt;
&lt;p&gt;must return whatever source we built it from (currently 13.0.1).&lt;/p&gt;
&lt;p&gt;Compile a dummy Windows program:&lt;/p&gt;
&lt;p&gt;echo -ne '#include &amp;lt;windows.h&amp;gt;\n#include &amp;lt;stdio.h&amp;gt;\nint main() {printf("Hello\n"); return 0;}\n' | x86_64-w64-mingw32-gcc -xc -&amp;lt;/stdio.h&amp;gt;&amp;lt;/windows.h&amp;gt;&lt;/p&gt;
&lt;p&gt;Run the output binary through the 'file' command to see that it's a Windows binary, or even copy it to a network path&lt;br/&gt;
that is also accessible from a Windows machine and run it.&lt;/p&gt;
&lt;h3 id="step-4-use-the-new-cross-compiler-to-cross-compile-the-same-gcc-sources-as-a-native-windows-compiler"&gt;Step 4: Use the new cross-compiler to cross-compile the same gcc sources as a native Windows compiler&lt;/h3&gt;
&lt;p&gt;Note: The cross-compiler must still be in the PATH.&lt;br/&gt;
Note: We are now using the native subfolders both for build and install.&lt;br/&gt;
Note: The --host configure option is now the same as the target, i.e. a native compiler, which is being&lt;br/&gt;
cross-compiled because the --build option is a Linux one (guessed).&lt;/p&gt;
&lt;p&gt;1) Build Windows-native binutils.&lt;/p&gt;
&lt;p&gt;cd $START_DIR/mingw-builds/build/native/binutils&lt;br/&gt;
../../../src/binutils/configure --prefix=$START_DIR/mingw-builds/install/native --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-multilib&lt;/p&gt;
&lt;p&gt;make -j$NUM_CORES&lt;br/&gt;
make install&lt;/p&gt;
&lt;p&gt;This creates Windows .exe binaries in install/native/bin and other folders under install/native&lt;/p&gt;
&lt;p&gt;2) Build Windows-native gcc.&lt;/p&gt;
&lt;p&gt;cd $START_DIR/mingw-builds/build/native/gcc&lt;br/&gt;
../../../src/gcc/configure --prefix=$START_DIR/mingw-builds/install/native --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-multilib --enable-languages=c,c++&lt;/p&gt;
&lt;p&gt;make -j$NUM_CORES&lt;br/&gt;
make install&lt;/p&gt;
&lt;p&gt;This installs the Windows .exe binaries in install/native/bin including gcc.exe and g++.exe&lt;br/&gt;
They don't have the target prefix any more as they are native Windows programs that don't run on Linux.&lt;/p&gt;
&lt;p&gt;Note: libgcc_s_seh-1.dll gets installed in lib, not bin.   Produced Windows binaries will crash if they&lt;br/&gt;
don't find it in bin, which has to be in the path anyway.&lt;/p&gt;
&lt;p&gt;Therefore just move it from lib to bin at this point (the gcc configure option --with-slibdir didn't do it):&lt;/p&gt;
&lt;p&gt;mv $START_DIR/mingw-builds/install/native/lib/libgcc_s_seh-1.dll $START_DIR/mingw-builds/install/native/bin/&lt;/p&gt;
&lt;p&gt;The new Windows-native gcc is almost ready.    It doesn't make sense to add this to the Linux path since it&lt;br/&gt;
is not a host (Linux) tool anyway.&lt;/p&gt;
&lt;p&gt;However, it cannot be used yet because it doesn't have the mingw-w64 headers and libs in its sysroot.&lt;/p&gt;
&lt;p&gt;At this point, install/native/x86_64-w64-mingw32/ has only the bin and lib subfolders coming from the&lt;br/&gt;
cross-compiled binutils.    It should also get the mingw-w64 headers and libs.&lt;/p&gt;
&lt;p&gt;3) Build mingw-w64 headers and libs (including winpthreads) and install into native toolchain sysroot.&lt;/p&gt;
&lt;p&gt;cd $START_DIR/mingw-builds/build/native/mingw-w64&lt;br/&gt;
../../../src/mingw-w64/configure --host=x86_64-w64-mingw32 --prefix=$START_DIR/mingw-builds/install/native/x86_64-w64-mingw32 --with-libraries=winpthreads&lt;/p&gt;
&lt;p&gt;Note: Unlike when we were building the cross-compiler, we don't have to install the mingw-w64 headers separately first.&lt;br/&gt;
Note: Again, deliberately leaving out parallelization here.    Try at your own risk.&lt;/p&gt;
&lt;p&gt;make&lt;br/&gt;
make install&lt;/p&gt;
&lt;p&gt;This adds libraries and headers in subfolders in the sysroot install/native/x86_64-w64-mingw32&lt;/p&gt;
&lt;p&gt;Note: libwinpthread-1.dll is in the sysroot bin folder, so move it to the toolchain bin folder in order&lt;br/&gt;
for it to be found by Windows running binaries, similar to what we did with libgcc_s_seh-1.dll above:&lt;/p&gt;
&lt;p&gt;mv $START_DIR/mingw-builds/install/native/x86_64-w64-mingw32/bin/libwinpthread-1.dll $START_DIR/mingw-builds/install/native/bin/&lt;/p&gt;
&lt;p&gt;The new Windows-native gcc toolchain is now ready.&lt;/p&gt;
&lt;p&gt;4) Package the native installation folder and deploy to Windows.&lt;/p&gt;
&lt;p&gt;cd $START_DIR/mingw-builds/install&lt;br/&gt;
(consider renaming 'native' do a different name if you want)&lt;br/&gt;
zip -r mingw64.zip native&lt;/p&gt;
&lt;p&gt;Copy it to a Windows machine, unzip, and use it.&lt;/p&gt;
&lt;p&gt;Suppose it was extracted in C:\native.   Add the bin subfolder to the Windows path:&lt;/p&gt;
&lt;p&gt;set PATH=C:\native\bin;%PATH%&lt;/p&gt;
&lt;p&gt;From Command Prompt, 'where gcc' should find gcc.exe&lt;/p&gt;
&lt;p&gt;Compile with gcc a C file that includes windows.h stdio.h pthread.h and uses pthreads (must compile with -pthread flag).&lt;br/&gt;
Compile with g++ a C++ file that includes C++11 &amp;lt;thread&amp;gt; and uses it.&amp;lt;/thread&amp;gt;&lt;/p&gt;
&lt;p&gt;Both should produce running Windows binaries.&lt;/p&gt;
&lt;p&gt;TODO: Add gmake to the build for a more complete toolchain.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Answer 64 bit MSVC-generated x64 .lib modified by Ozkan Sezer</title><link href="https://sourceforge.net/p/mingw-w64/wiki2/Answer%252064%2520bit%2520MSVC-generated%2520x64%2520.lib/" rel="alternate"/><published>2022-09-13T20:55:17.683000Z</published><updated>2022-09-13T20:55:17.683000Z</updated><author><name>Ozkan Sezer</name><uri>https://sourceforge.net/u/sezero/</uri></author><id>https://sourceforge.netfb3011dd247275900594f155ccc65d65ac14ecfc</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -1,5 +1,5 @@
 **Q:**  
-Why crashes my 64 bit program when using a MSVC-generate x64 *`.lib` file? 
+Why crashes my 64 bit program when using a MSVC-generated x64 import library? 

 **A:**  
 Linking using an MSVC-generated x64 `*.lib` file is _not_ supported.
&lt;/pre&gt;
&lt;/div&gt;</summary></entry></feed>