Tag Archives: win32

Linux hosted mingw w64 C,C++ and Java cross compiler

Hi everyone !

As i said in my previous article, i want to share with you about the steps to get a fully working w64-mingw32 gcc and gcj 4.6.0 toolchain. I’ll try to be as accurate as possible. Despite of all my efforts, I didn’t manage to get the multilib compiler to build, so I will only describe the steps to get an i686 compiler. Most of the content of this post is based upon mingw w64 instructions, but as I didn’t manage to get it fully compiling following theses instructions, that’s why I’m writing this post.

The times given in this article are thoses obtained with an Intel Xeon CPU X5560 @ 2.80GHz.
The gcc version used was:
gcc version 4.1.2 20080704 (Red Hat 4.1.2-48).


  • Native working gcc/gcj installed (at least 4.1), for i686 architecture
  • Environment variables:
    • $work = directory where to work (for example, $HOME/mingw)
    • $prefix = directory where to install the cross compiler (for example, $work/root)
    • $CFLAGS = optimization flags (for example “-march=core2 -mtune=core2 -O2 -pipe”, see Safe CFLAGS for how to define them),
  • Directories:
    • mkdir -p $work/sources $work/tarballs $work/builds $prefix


Retrieve the following sources in the directory $work/tarballs:

  1. binutils 2.21.51
  2. gcc 4.6.1 20110401: core, g++, java, fix for libjava build error, fix for boehm-gc dll exports, fix for gcj spec file
  3. mingw-w64-trunk-r4105-20110404
  4. ecj 4.5
  5. ppl 11.2, cloog 0.16.2
  6. mpfr 3.0.1, gmp 5.0.1, mpc 0.9

Once everything is retrieved, check that files you downloaded are valid using provided sha1sums.txt (download it to $work/tarballs) and the following command:

# cd $work/tarballs
# sha1sum -c sha1sums.txt
binutils-2.21.51.tar.bz2: OK
cloog-0.16.2.tar.gz: OK
ecj-4.5.jar: OK
gcc-4.6.1-20110401-fix-boehm-gc-dll-export.patch: OK
gcc-4.6.1-20110401-fix-gcj-spec-file.patch: OK
gcc-4.6.1-20110401-fix-libjava-reflect-build-error.patch: OK
gcc-core-4.6-20110401.tar.bz2: OK
gcc-g++-4.6-20110401.tar.bz2: OK
gcc-java-4.6-20110401.tar.bz2: OK
gmp-5.0.1.tar.bz2: OK
mingw-w64-trunk-r4105-20110404.tbz2: OK
mpc-0.9.tar.gz: OK
mpfr-3.0.1.tar.bz2: OK
ppl-0.11.2.tar.bz2: OK

Read more »