Difference between revisions of "Building MINGW-w64"
(Fix a typo :)) |
|||
(22 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
This guide is provided for those who have no clue how to compile gcc, but still want to do it. It's a reference, just follow the steps and you get what you want. There's no support for special wishes ;-) | This guide is provided for those who have no clue how to compile gcc, but still want to do it. It's a reference, just follow the steps and you get what you want. There's no support for special wishes ;-) | ||
− | = Setting up the build environment = | + | == Setting up the build environment == |
Download and install MSYS. You will need the following packages: | Download and install MSYS. You will need the following packages: | ||
− | * MSYS-w64 (version [http:// | + | * MSYS-w64 (version [http://heanet.dl.sourceforge.net/project/mingw-w64/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/MSYS-20111123.zip 20111123]) |
− | * make (version [http:// | + | * make (version [http://heanet.dl.sourceforge.net/project/mingw-w64/External%20binary%20packages%20%28Win64%20hosted%29/make/make-3.82.90-20111115.zip 3.82.90]) |
* Recent mingw-w64 32 bit Toolchain ([http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Automated%20Builds/ here]) Choose a file like: mingw-w32-1.0-bin_i686-mingw_%NEWESTDATE%.zip | * Recent mingw-w64 32 bit Toolchain ([http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Automated%20Builds/ here]) Choose a file like: mingw-w32-1.0-bin_i686-mingw_%NEWESTDATE%.zip | ||
Line 16: | Line 16: | ||
* DONT FORGET the postinstall script | * DONT FORGET the postinstall script | ||
− | = Getting the sources = | + | == Getting the sources == |
Download all the sources into subfolders of /src | Download all the sources into subfolders of /src | ||
− | * binutils (version [ftp://sourceware.org/pub/binutils/snapshots/binutils-2. | + | * binutils (version [ftp://sourceware.org/pub/binutils/snapshots/binutils-2.22.53.tar.bz2 2.22.53] or [ftp://sourceware.org/pub/binutils/snapshots/ newer]) -> /src/binutils |
− | * gcc-core (version [ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.6. | + | * gcc-core (version [ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.6.3/gcc-core-4.6.3.tar.bz2 4.6.3] or [ftp://ftp.fu-berlin.de/unix/languages/gcc/snapshots/ newer]) -> /src/gcc |
− | * gcc-g++ (version [ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.6. | + | * gcc-g++ (version [ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.6.3/gcc-g++-4.6.3.tar.bz2 4.6.3] or [ftp://ftp.fu-berlin.de/unix/languages/gcc/snapshots/ newer]) -> /src/gcc |
− | * mingw-w64 ([http://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-snapshot/ here]) -> /src/mingw-w64 | + | * mingw-w64 v2.0.3 ([http://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-snapshot/ here]) -> /src/mingw-w64 |
− | * MPFR (version [http://mpfr.loria.fr/mpfr-current/mpfr-3.0 | + | * MPFR (version [http://mpfr.loria.fr/mpfr-current/mpfr-3.1.0.zip 3.1.0]) -> /src/mpfr |
− | * GMP (version [ftp://ftp.gmplib.org/pub/gmp-5.0. | + | * GMP (version [ftp://ftp.gmplib.org/pub/gmp-5.0.5/gmp-5.0.5.tar.bz2 5.0.5]) -> /src/gmp |
* MPC (version [http://www.multiprecision.org/mpc/download/mpc-0.9.tar.gz 0.9]) -> /src/mpc | * MPC (version [http://www.multiprecision.org/mpc/download/mpc-0.9.tar.gz 0.9]) -> /src/mpc | ||
− | |||
− | |||
− | = Note = | + | == Note == |
Copy the src/mingw-w64/mingw-w64-headers/include directory to /RosBE64/mingw and to /RosBE64/x86_64-w64-mingw32 (64 bit) or /RosBE64/i686-w64-mingw32 (32 bit). | Copy the src/mingw-w64/mingw-w64-headers/include directory to /RosBE64/mingw and to /RosBE64/x86_64-w64-mingw32 (64 bit) or /RosBE64/i686-w64-mingw32 (32 bit). | ||
− | == Patching the sources == | + | === Patching the sources === |
You need to apply 2 patches (Kudos go to Kai Tietz from mingw-w64): | You need to apply 2 patches (Kudos go to Kai Tietz from mingw-w64): | ||
Line 50: | Line 48: | ||
32 bit: | 32 bit: | ||
− | export CFLAGS="-g0 -O2 -pipe -Wl,-S -march=i686" | + | export CFLAGS="-g0 -O2 -pipe -Wl,-S -march=pentium -mtune=i686" |
− | export CXXFLAGS="-g0 -O2 -pipe -Wl,-S -march=i686" | + | export CXXFLAGS="-g0 -O2 -pipe -Wl,-S -march=pentium -march=i686" |
− | == Building GMP == | + | === Building GMP === |
Create a build subdirectory for gmp: | Create a build subdirectory for gmp: | ||
Line 65: | Line 63: | ||
Now build the whole stuff. | Now build the whole stuff. | ||
− | make CPPFLAGS=-fexceptions | + | make CPPFLAGS="-fexceptions" |
Finally install it into the designated directory. | Finally install it into the designated directory. | ||
make install | make install | ||
− | == Building MPFR == | + | === Building MPFR === |
Create a build subdirectory for mpfr: | Create a build subdirectory for mpfr: | ||
Line 87: | Line 85: | ||
make install | make install | ||
− | == Building MPC == | + | === Building MPC === |
Create a build subdirectory for mpc: | Create a build subdirectory for mpc: | ||
Line 105: | Line 103: | ||
make install | make install | ||
− | + | === Building binutils === | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Create a build subdirectory for binutils: | Create a build subdirectory for binutils: | ||
Line 163: | Line 126: | ||
make install | make install | ||
− | == Building gcc-core == | + | === Building gcc-core === |
− | + | Enter into the build directory: | |
cd .. | cd .. | ||
mkdir gcc | mkdir gcc | ||
Line 173: | Line 136: | ||
64 bit: | 64 bit: | ||
../../src/gcc/configure --prefix=/RosBE64 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=x86_64-w64-mingw32 | ../../src/gcc/configure --prefix=/RosBE64 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=x86_64-w64-mingw32 | ||
− | --with-gmp=/support --with-mpfr=/support --with-mpc=/support | + | --with-gmp=/support --with-mpfr=/support --with-mpc=/support --with-pkgversion="RosBE-Windows" |
− | + | --enable-languages=c,c++ --enable-checking=release --disable-win32-registry --disable-shared --disable-nls --disable-werror | |
− | + | --disable-multilib --with-sysroot=/RosBE64 --enable-version-specific-runtime-libs --with-host-libstdcxx="-lstdc++ -lsupc++" | |
− | |||
32 bit: | 32 bit: | ||
../../src/gcc/configure --prefix=/RosBE64 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 | ../../src/gcc/configure --prefix=/RosBE64 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 | ||
− | --with-gmp=/support --with-mpfr=/support --with-mpc=/support | + | --with-gmp=/support --with-mpfr=/support --with-mpc=/support --with-pkgversion="RosBE-Windows" |
− | + | --enable-languages=c,c++ --enable-checking=release --disable-win32-registry --disable-shared --disable-nls --disable-werror | |
− | + | --disable-multilib --with-sysroot=/RosBE64 --enable-version-specific-runtime-libs --with-host-libstdcxx="-lstdc++ -lsupc++" | |
− | |||
Compile the gcc-core | Compile the gcc-core | ||
Line 194: | Line 155: | ||
PATH=$PATH:/RosBE64/bin ; export PATH | PATH=$PATH:/RosBE64/bin ; export PATH | ||
− | == Building the crt == | + | === Building the crt === |
Create a build directory. | Create a build directory. | ||
Line 217: | Line 178: | ||
Copy the /RosBE64/x86_64-w64-mingw32 (64 bit) or /RosBE64/i686-w64-mingw32 (32 bit) directory to /RosBE64/mingw. | Copy the /RosBE64/x86_64-w64-mingw32 (64 bit) or /RosBE64/i686-w64-mingw32 (32 bit) directory to /RosBE64/mingw. | ||
− | == Building the rest of gcc == | + | === Building the rest of gcc === |
Enter into the gcc build directory. | Enter into the gcc build directory. | ||
cd .. | cd .. | ||
Line 226: | Line 187: | ||
make install | make install | ||
− | = Common errors = | + | == Common errors == |
When compiling crt: | When compiling crt: | ||
Line 237: | Line 198: | ||
[[Category:Building]] | [[Category:Building]] | ||
[[Category:amd64]] | [[Category:amd64]] | ||
+ | [[Category:Tutorial]] |
Revision as of 09:14, 14 July 2013
... for idiots. This guide is provided for those who have no clue how to compile gcc, but still want to do it. It's a reference, just follow the steps and you get what you want. There's no support for special wishes ;-)
Contents
Setting up the build environment
Download and install MSYS. You will need the following packages:
- MSYS-w64 (version 20111123)
- make (version 3.82.90)
- Recent mingw-w64 32 bit Toolchain (here) Choose a file like: mingw-w32-1.0-bin_i686-mingw_%NEWESTDATE%.zip
Download all packages and extract them into c:\MSYS (or similar).
Additional steps needed are:
- Go to the bin folder inside msys and copy and rename i686-w64-*.exe to *.exe to make configure happy
- Delete dlfcn.h in every location.
- DONT FORGET the postinstall script
Getting the sources
Download all the sources into subfolders of /src
- binutils (version 2.22.53 or newer) -> /src/binutils
- gcc-core (version 4.6.3 or newer) -> /src/gcc
- gcc-g++ (version 4.6.3 or newer) -> /src/gcc
- mingw-w64 v2.0.3 (here) -> /src/mingw-w64
Note
Copy the src/mingw-w64/mingw-w64-headers/include directory to /RosBE64/mingw and to /RosBE64/x86_64-w64-mingw32 (64 bit) or /RosBE64/i686-w64-mingw32 (32 bit).
Patching the sources
You need to apply 2 patches (Kudos go to Kai Tietz from mingw-w64):
- Patch for binutils (Obsolete)
- Patch for gcc (Obsolete)
Building
Optionally set buildflags:
64 bit:
export CFLAGS="-g0 -O2 -pipe -Wl,-S" export CXXFLAGS="-g0 -O2 -pipe -Wl,-S"
32 bit:
export CFLAGS="-g0 -O2 -pipe -Wl,-S -march=pentium -mtune=i686" export CXXFLAGS="-g0 -O2 -pipe -Wl,-S -march=pentium -march=i686"
Building GMP
Create a build subdirectory for gmp:
cd build mkdir gmp cd gmp
From the build directory run the gmp configure script:
../../src/gmp/configure --prefix=/support --host=i686-w64-mingw32 --build=i686-w64-mingw32 --enable-cxx --disable-shared
Now build the whole stuff.
make CPPFLAGS="-fexceptions"
Finally install it into the designated directory.
make install
Building MPFR
Create a build subdirectory for mpfr:
cd build mkdir mpfr cd mpfr
From the build directory run the mpfr configure script:
../../src/mpfr/configure --prefix=/support --host=i686-w64-mingw32 --build=i686-w64-mingw32 --with-gmp=/support --disable-shared
Now build the whole stuff.
make
Finally install it into the designated directory.
make install
Building MPC
Create a build subdirectory for mpc:
cd build mkdir mpc cd mpc
From the build directory run the mpc configure script:
../../src/mpc/configure --prefix=/support --host=i686-w64-mingw32 --build=i686-w64-mingw32 --with-gmp=/support --with-mpfr=/support --disable-shared
Now build the whole stuff.
make
Finally install it into the designated directory.
make install
Building binutils
Create a build subdirectory for binutils:
cd build mkdir binutils cd binutils
From the build directory run the binutils configure script:
64 bit:
../../src/binutils/configure --prefix=/RosBE64 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=x86_64-w64-mingw32 --disable-nls --disable-werror --disable-multilib --with-sysroot=/RosBE64
32 bit:
../../src/binutils/configure --prefix=/RosBE64 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --disable-nls --disable-werror --disable-multilib --with-sysroot=/RosBE64
Now build the whole stuff.
make
Finally install it into the designated directory.
make install
Building gcc-core
Enter into the build directory:
cd .. mkdir gcc cd gcc
Now run the configure script:
64 bit:
../../src/gcc/configure --prefix=/RosBE64 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=x86_64-w64-mingw32 --with-gmp=/support --with-mpfr=/support --with-mpc=/support --with-pkgversion="RosBE-Windows" --enable-languages=c,c++ --enable-checking=release --disable-win32-registry --disable-shared --disable-nls --disable-werror --disable-multilib --with-sysroot=/RosBE64 --enable-version-specific-runtime-libs --with-host-libstdcxx="-lstdc++ -lsupc++"
32 bit:
../../src/gcc/configure --prefix=/RosBE64 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --with-gmp=/support --with-mpfr=/support --with-mpc=/support --with-pkgversion="RosBE-Windows" --enable-languages=c,c++ --enable-checking=release --disable-win32-registry --disable-shared --disable-nls --disable-werror --disable-multilib --with-sysroot=/RosBE64 --enable-version-specific-runtime-libs --with-host-libstdcxx="-lstdc++ -lsupc++"
Compile the gcc-core
make all-gcc
And install it
make install-gcc
Finally add it to the PATH variable.
PATH=$PATH:/RosBE64/bin ; export PATH
Building the crt
Create a build directory.
cd .. mkdir mingw-w64-crt cd mingw-w64-crt
Run the configure script
64 bit:
../../src/mingw-w64/mingw-w64-crt/configure --prefix=/RosBE64 --host=x86_64-w64-mingw32 --build=i686-w64-mingw32 --with-sysroot=/RosBE64
32 bit:
../../src/mingw-w64/mingw-w64-crt/configure --prefix=/RosBE64 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --with-sysroot=/RosBE64
Compile
make
And install
make install
Copy the /RosBE64/x86_64-w64-mingw32 (64 bit) or /RosBE64/i686-w64-mingw32 (32 bit) directory to /RosBE64/mingw.
Building the rest of gcc
Enter into the gcc build directory.
cd .. cd gcc
And compile the rest.
make make install
Common errors
When compiling crt:
configure: error: Please check if the mingw-w64 header set and the build/host option are set properly.
- Check if you have copied the mingw-headers/include directory to both /RosBE64/x86_64-w64-mingw32 and /RosBE64/mingw
- Check if you have set the PATH variable to the new compiler correctly
- Check if you have installed the new compiler correctly ("make install-gcc")