MinGW-w64 Build Script 2.8.4

This version is outdated, the newest release of this script can be found at: http://ffmpeg.zeranoe.com/blog/?cat=4

This is a new release of my MinGW-w64 Build Script


Some key features of this script are:

  • Builds both win32 and win64 toolchains.
  • Checks for missing packages before the compile begins.
  • Builds are “full featured” toolchain (ppl and cloog).
  • Can choose between a Win32 or Win64 build, or choose to compile both.
  • Automatically detects a previous built toolchain and updates the toolchain instead of a full rebuild.
  • pthreads is automatically built and installed.
  • Builds a toolchain that can compile FFmpeg for Win32 and Win64, along with the external libraries.
  • Automatically stops the script if any package fails to build.
  • Support for make “jobs” which will use multiple CPU cores/threads.
  • Allow user to choose which version of GCC and Binutils to build.
  • Allow for a fully static build.
  • Clean the build after the build finishes.
  • Allow the user to select which languages to build into GCC
  • Allow the user to build without NLS support


Some changes/fixes from version 2.8.2 are:

  • Update to GCC 4.6.2
  • Update to Binutils 2.22


Please download and try it, even if you don’t want to use the resulting toolchain I could use some feedback and bug reports.

I made sure that it’s simple yet effective, you wont be prompted for most things (though if you would like more prompts then feel free to ask/recommend).

This script has been tested on Ubuntu 64-bit, Ubuntu 32-bit, Debian 64-bit, and it should work on any Linux that supports bash.


Download it here: http://www.zeranoe.com/scripts/mingw_w64_build/mingw-w64-build-2.8.4

or bz2 here:http://www.zeranoe.com/scripts/mingw_w64_build/mingw-w64-build-2.8.4.tar.bz2


Here are the steps to get the script running:

  1. Download it here: http://www.zeranoe.com/scripts/mingw_w64_build/mingw-w64-build-2.8.4 or the command line way (make sure your in the directory you want to save it to): wget http://www.zeranoe.com/scripts/mingw_w64_build/mingw-w64-build-2.8.4
  2. The script is also available in a bz2 archive if you need would like that instead: http://www.zeranoe.com/scripts/mingw_w64_build/mingw-w64-build-2.8.4.tar.bz2
  3. Save it to the directory that you want MinGW-w64 to build in, e.g: /home/<username>/software/mingw-w64 or ~/software/mingw-w64
  4. Change to that directory from the terminal: cd ~/software/mingw-w64 (or whatever path your using).
  5. Change the permissions of the script so that it can be executed by you: chmod 755 mingw-w64-build-2.8.4
  6. Run the script: bash mingw-w64-build-2.8.4


The script is released under GPL v3.0

18 thoughts on “MinGW-w64 Build Script 2.8.4”

  1. I am having problem using the tool chain after its downloaded.. I always get this i686-w64-mingw32-gcc is unable to create an executable file.
    C compiler test failed.

    i even set the path to the folder where thats created first.. and it fails then too..

      1. Could this be the issue?
        – The options -b and -V have been removed because they were unreliable. Instead, users should directly run -gcc when cross-compiling, or -gcc- to run a different version of gcc. (gcc version 4.6 official release note)

        I ran the package and I kept on getting the error saying C compiler cannot create executables, and when I checked the log file created this seems to be the problem. Will try to install an earlier version of gcc to double check. Meanwhile PLEASEEEE let me know if you can update the package :)

      2. Ops forgot to post the error log. This is the interesting part:
        configure:4018: $? = 0
        configure:4007: gcc -v >&5
        Using built-in specs.
        Target: i686-linux-gnu
        Configured with: ../src/configure -v –with-pkgversion=’Ubuntu/Linaro 4.6.3-1ubuntu5′ –with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs –enable-languages=c,c++,fortran,objc,obj-c++ –prefix=/usr –program-suffix=-4.6 –enable-shared –enable-linker-build-id –with-system-zlib –libexecdir=/usr/lib –without-included-gettext –enable-threads=posix –with-gxx-include-dir=/usr/include/c++/4.6 –libdir=/usr/lib –enable-nls –with-sysroot=/ –enable-clocale=gnu –enable-libstdcxx-debug –enable-libstdcxx-time=yes –enable-gnu-unique-object –enable-plugin –enable-objc-gc –enable-targets=all –disable-werror –with-arch-32=i686 –with-tune=generic –enable-checking=release –build=i686-linux-gnu –host=i686-linux-gnu –target=i686-linux-gnu
        Thread model: posix
        gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
        configure:4018: $? = 0
        configure:4007: gcc -V >&5
        gcc: error: unrecognized option ‘-V’
        gcc: fatal error: no input files
        compilation terminated.

  2. I have the ffmpeg source on my linux(Ubuntu 11.10) box, and I have created the static build I want for Linux from that (using “./configure [options] \make ) I need to make a static build of this same ffmpeg source but for windows.

    After installing this tool chain is it as simple as a option in ./configure that will build a Win32 version of ffmpeg or is there more to be done? If so what is the configure flag, if not how do you build ffmpeg from it’s source?

  3. I successfully built ffmpeg from source using this toolchain and the command:
    ./configure –enable-memalign-hack –arch=x86 –target-os=mingw32 –cross-prefix=i686-w64-mingw32- –enable=w32threads –enable-gpl

    When I try to add support for other codecs it doesn’t seem to be able to find these. These are codecs that I have installed and work when building ffmpeg not using your toolchain. Are there any steps needed to ensure mingw32 can find additional codecs.

  4. After installing the script i tried to compile a simple helloworld.cxx…

    int main()
    std::cout << "Hello world" << std::endl;

    it produced the following error
    error trying to exec 'cc1plus': execvp

    I used sudo apt-get install gcc-mingw-w64 and it seemed to repair the problems

  5. error on running this script fresh ubuntu 11.10
    collect2: ld returned 1 exit status
    make[2]: *** [libgcc_s.dll] Error 1
    make[2]: Leaving directory `/home/rb/mingw-w64z/packages/gcc/build/x86_64-w64-mingw32/libgcc’
    make[1]: *** [all-target-libgcc] Error 2
    make[1]: Leaving directory `/home/rb/mingw-w64z/packages/gcc/build’
    make: *** [all] Error 2

  6. FYI: I tested the script on Ubuntu 11.10, Slackware 13.37 and Fedora 16.
    On Ubuntu 11.10 it works without any adjustment (just like in Debian, I suppose).
    On Fedora it stops for unresolved dependences of GLIBC (cannot find a symbol in libm.so.6).
    On Slackware 13.37 it works well too!
    The testing systems are all VirtualBox Machines with 1GB Ram and 4 cores (I have a Intel® Core™ 2 Quad Q8800)

  7. Hi, thanks a lot for your work done on this topic.

    I tried your script on a Debian 6.0.4 64bit Installation and got the following error:

    /mingw-w64/packages/gcc/packages/gmp/gmp-5.0.2-x86_64/lib/libgmpxx.a /usr/src/mingw-w64/packages/gcc/packages/gmp/gmp-5.0.2-x86_64/lib/libgmp.a -lstdc++
    /usr/local/bin/ld: /usr/src/mingw-w64/packages/gcc/packages/ppl/ppl-0.11.2-x86_64/lib/libppl_c.a(ppl_c_implementation_common.o): undefined reference to symbol ‘fesetround@@GLIBC_2.2.5’
    /usr/local/bin/ld: note: ‘fesetround@@GLIBC_2.2.5′ is defined in DSO /lib64/libm.so.6 so try adding it to the linker command line
    /lib64/libm.so.6: could not read symbols: Invalid operation
    collect2: ld returned 1 exit status
    make[1]: *** [cloog] Fehler 1
    make[1]: Leaving directory `/usr/src/mingw-w64/packages/gcc/packages/cloog-ppl/build’
    make: *** [all-recursive] Fehler 1

    Any hint how i can fix this?

    Thanks a lot

  8. Running on Ubuntu I got

    make[1]: Leaving directory `/home/wier/teqc/mingw64/zeranoe/packages/gcc/packages/gmp/build’
    –2012-08-21 13:35:46– http://www.mpfr.org/mpfr-current/mpfr-3.1.0.tar.bz2
    Resolving http://www.mpfr.org...
    Connecting to http://www.mpfr.org||:80… connected.
    HTTP request sent, awaiting response… 404 Not Found
    2012-08-21 13:35:48 ERROR 404: Not Found.

    tar: mpfr-3.1.0.tar.bz2: Cannot open: No such file or directory
    tar: Error is not recoverable: exiting now
    tar: Child returned status 2
    tar: Exiting with failure status due to previous errors
    removed directory: `build’
    mingw-w64-build-2.8.4: line 504: ../source/mpfr-3.1.0/configure: No such file or directory

    yet http://www.mpfr.org is online and seen in my browser

    So how do I resume the build, and get over this obstacle? Try it again from the top?


  9. Now is an error ;
    mingw64/zeranoe/mingw-w64-x86_64/x86_64-w64-mingw32/bin/as: unrecognized option ‘-Qy’

    what is bin/as doing?


    /bin/bash ../../source/gcc-4.5.3/gcc/mkconfig.sh bconfig.h
    gcc -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -DNATIVE_CROSS -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../../source/gcc-4.5.3/gcc -I../../source/gcc-4.5.3/gcc/build -I../../source/gcc-4.5.3/gcc/../include -I../../source/gcc-4.5.3/gcc/../libcpp/include -I/home/wier/teqc/mingw64/zeranoe/packages/gcc/packages/gmp/gmp-4.3.2-i686/include -I/home/wier/teqc/mingw64/zeranoe/packages/gcc/packages/mpfr/mpfr-3.1.1-i686/include -I/home/wier/teqc/mingw64/zeranoe/packages/gcc/packages/mpc/mpc-0.9-i686/include -I../../source/gcc-4.5.3/gcc/../libdecnumber -I../../source/gcc-4.5.3/gcc/../libdecnumber/dpd -I../libdecnumber -I/home/wier/teqc/mingw64/zeranoe/packages/gcc/packages/ppl/ppl-0.10.2-i686/include -I/home/wier/teqc/mingw64/zeranoe/packages/gcc/packages/cloog-ppl/cloog-ppl-0.15.11-i686/include -DCLOOG_PPL_BACKEND \
    -o build/genmodes.o ../../source/gcc-4.5.3/gcc/genmodes.c
    /home/wier/teqc/mingw64/zeranoe/mingw-w64-x86_64/x86_64-w64-mingw32/bin/as: unrecognized option ‘-Qy’
    make[1]: *** [build/genmodes.o] Error 1

Leave a Reply