HowTo build x86_64-pc-mingw32 cross-compiler | |
Date / Version / Author | |
2007-07-31 1.0 Kai Tietz <Kai.Tietz at onevision.com> | |
2007-08-20 1.1 Kai Tietz <Kai.Tietz at onevision.com> | |
This document describes how to build the amd64 mingw32 gcc toolchain as cross-compiler on cygwin and unix shells. | |
1. Download packages | |
The following packages you need to download | |
- binutils 2.17.50 snapshot released after or equal to the 1st of Junly 2007. | |
- gcc version 4.3 snapshort released after or equal to the 1st of Junly 2007. | |
- current mingw-w64-snapshot available on the sourceforge 'mingw-w64' | |
Now extract these tarballs in an temporary folder. E.g. use ~/w64src. For the tarballs with | |
extension .tar.gz or .tgz use the following command to extract : tar -xzf <tarball>'. For | |
tarballs with extension .tar.bz2 or .tbz2 use the command 'tar -xjf <tarball>'. | |
There are now three folders within you temporary folder: trunk, binutils, and gcc. | |
2. Choice of kind of build | |
You have at least two different choices to build the crosscompiler toolchain: | |
I) Using standard settings of configure. | |
II) Using --prefix and --with-sysroot configuration | |
I assume that <install-root> is for build kind I '/usr/local' and for kind II your specified | |
path. | |
Building binutils cross toolchain: | |
Step 1) Enter into the binutils root folder and generate a folder within (e.g. | |
'build'). Than enter into it. | |
Step 2 for I) Type '../configure --target=x86_64-pc-mingw32' | |
Step 2 for II) Type '../configure --target=x86_64-pc-mingw32 --prefix=/vol/m --with-sysroot=/vol/m'. | |
May change the pathes '/vol/m' to pathes you desire. | |
Step 3) Type 'make' | |
Step 4) Type 'make install' | |
Now copy the content of the folder 'trunk/mingw-w64-headers/include' into your '<install-root>/x86_64-pc-mingw32/include' | |
folder. If you choose the configuration variant II create in <install-root> a symbolic link named | |
'mingw' pointing to the directory 'x86_64-pc-mingw32'. | |
Building the gcc core cross-compiler(s): | |
Step 0) If you have to patch gcc, may do this here. There are some patches necessary, if you want | |
to cross compile libiberty with early header sets, or if you want to use gfortran. These patches | |
are available by the 'gcc-patches' mailing list at 'gcc.gnu.org' or by taking a look at mingw.org | |
or mingw-w64 sites. | |
Step 1) Enter into the gcc root folder and generate a folder within (e.g. 'build'). Than may you | |
apply optional patches to gcc (currently there is a patch file for gcc needed to fix some | |
problems about autoimported variables, libiberty and the fortan compiler). | |
Step 2 for I) Now enter into your created folder (e.g. 'build') and type | |
'../configure --target=x86_64-pc-mingw32'. | |
Step 2 for II) Now enter into your created folder (e.g. 'build') and type | |
'../configure --target=x86_64-pc-mingw32 --prefix=/vol/m --with-sysroot=/vol/m'. | |
May change the pathes '/vol/m' to pathes you desire. | |
Step 3) Type 'make all-gcc' | |
Step 4) Type 'make install-gcc' | |
Now the core stuff of gcc is present and we can build the crt itself. | |
Building the crt: | |
Step 0) If you are using variant II, may you need to adjust the 'prefix' value in Makefiles. | |
Step 1) Enter into the trunk/mingw-w64-crt root directory. | |
Step 2) Type 'make' | |
Step 3) Copy all generated *.a files out of the 'mklibs' folder into the | |
'<install-root>/x86_64-pc-mingw32/lib' folder. | |
Step 4) Copy out of the root folder to the '<install-root>/x86_64-pc-mingw32/lib' folder the files | |
crt1.o, crt2.o, lib*.a, *.dll, crtbegin.o, crtend.o, dllcrt1.o, dllcrt2.o, binmode.o, txtmode.o, | |
CRT_fp8.o, and the CRT_fp10.o. | |
Now you are ready to build the rest of gcc: | |
Step 1) Enter into your generated folder within your gcc root source folder. | |
Step 2) Type 'make' | |
Step 3) Type 'make install' | |