Building GCC Dependencies in the MinGW VM

Usually GCC prerequisite libraries (libmpc, libmpfr and libgmp) can be installed via MinGW package manager. This time they were build from source because of MinGW repository server was down.

Important note: --build and --host options are here to prevent libraries from binding to latest CPU features like AVX2.

  1. Update C:\MinGW\msys\1.0\opt\crosstool\src\build_gcc_cross.sh :

    #!/bin/bash
    export PATH=.:/usr/local/bin:/mingw/bin:/bin
    export PATH=$PATH:/c/WINDOWS/system32:/c/WINDOWS
    export PATH=$PATH:/c/WINDOWS/System32/Wbem
    
    cd /opt/crosstool/src/build-gmp
    ../gmp-5.1.2/configure \
       --build=i586-pc-mingw32 --host=i586-pc-mingw32 \
       --disable-shared --enable-static
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to configure libgmp ==="
        exit 1
    fi
    make
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to make libgmp ==="
        exit 1
    fi
    make check
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to check libgmp ==="
        exit 1
    fi
    make install
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to install libgmp ==="
        exit 1
    fi
    
    cd /opt/crosstool/src/build-mpfr
    ../mpfr-3.1.2/configure \
       --build=i586-pc-mingw32 --host=i586-pc-mingw32 \
       --with-gmp=/usr/local --disable-shared --enable-static
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to configure libmpfr ==="
        exit 1
    fi
    make
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to make libmpfr ==="
        exit 1
    fi
    make check
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to check libmpfr ==="
        exit 1
    fi
    make install
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to install libmpfr ==="
        exit 1
    fi
    
    cd /opt/crosstool/src/build-mpc
    ../mpc-1.0.2/configure \
       --build=i586-pc-mingw32 --host=i586-pc-mingw32 \
       --with-gmp=/usr/local --disable-shared --enable-static
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to configure libmpc ==="
        exit 1
    fi
    make
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to make libmpc ==="
        exit 1
    fi
    make check
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to check libmpc ==="
        exit 1
    fi
    make install
    if [ "$?" -ne "0" ]; then
        echo "=== build script: failed to install libmpc ==="
        exit 1
    fi
    
    echo "=== build script: OK ==="
    

  2. Run C:\MinGW\msys\1.0\opt\crosstool\src\build_gcc_cross.cmd and wait until it completes.
  3. If there are no errors, shutdown MinGW VM and make snapshot "SNAP-C".


>> Read next section or buy already prepared cross-compiler (€10) to save your time.