Difference between revisions of "Building MINGW-w64"

From ReactOS Wiki
Jump to: navigation, search
Line 32: Line 32:
 
== 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 /RosBE/mingw and to /RosBE/x86_64-w64-mingw32 (64 bit) or /RosBE/i686-w64-mingw32 (32 bit).
  
 
WARNING!! Might be obsolete. Have to recheck
 
WARNING!! Might be obsolete. Have to recheck
Line 58: Line 58:
  
 
64 bit:
 
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
+
  ../../src/binutils/configure --prefix=/RosBE --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=x86_64-w64-mingw32 --disable-nls --disable-werror --disable-multilib --with-sysroot=/RosBE
  
 
32 bit:
 
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
+
  ../../src/binutils/configure --prefix=/RosBE --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --disable-nls --disable-werror --disable-multilib --with-sysroot=/RosBE
  
 
Now build the whole stuff.
 
Now build the whole stuff.
Line 78: Line 78:
  
 
64 bit:
 
64 bit:
  ../../src/gcc/configure --prefix=/RosBE64 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=x86_64-w64-mingw32 --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++"
+
  ../../src/gcc/configure --prefix=/RosBE --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=x86_64-w64-mingw32 --with-pkgversion="RosBE-Windows" --enable-languages=c,c++ --enable-checking=release --disable-win32-registry --disable-shared --disable-nls --disable-werror --disable-multilib --with-sysroot=/RosBE --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 --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++"
+
  ../../src/gcc/configure --prefix=/RosBE --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --with-pkgversion="RosBE-Windows" --enable-languages=c,c++ --enable-checking=release --disable-win32-registry --disable-shared --disable-nls --disable-werror --disable-multilib --with-sysroot=/RosBE --enable-version-specific-runtime-libs --with-host-libstdcxx="-lstdc++ -lsupc++"
  
 
Compile the gcc-core
 
Compile the gcc-core
Line 90: Line 90:
  
 
Finally add it to the PATH variable.
 
Finally add it to the PATH variable.
  export PATH="$PATH:/RosBE64/bin"
+
  export PATH="$PATH:/RosBE/bin"
  
 
=== Building the mingw-w64 headers ===
 
=== Building the mingw-w64 headers ===
Line 102: Line 102:
  
 
64 bit:
 
64 bit:
  ../../src/mingw-w64/mingw-w64-headers/configure --host=x86_64-w64-mingw32 --build=i686-w64-mingw32 --prefix=/RosBE64/x86_64-w64-mingw32
+
  ../../src/mingw-w64/mingw-w64-headers/configure --host=x86_64-w64-mingw32 --build=i686-w64-mingw32 --prefix=/RosBE/x86_64-w64-mingw32
  
 
32 bit:
 
32 bit:
  ../../src/mingw-w64/mingw-w64-headers/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --prefix=/RosBE64/i686-w64-mingw32
+
  ../../src/mingw-w64/mingw-w64-headers/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --prefix=/RosBE/i686-w64-mingw32
  
 
Install
 
Install
Line 113: Line 113:
  
 
64 bit:
 
64 bit:
  ../../src/mingw-w64/mingw-w64-headers/configure --host=x86_64-w64-mingw32 --build=i686-w64-mingw32 --prefix=/RosBE64
+
  ../../src/mingw-w64/mingw-w64-headers/configure --host=x86_64-w64-mingw32 --build=i686-w64-mingw32 --prefix=/RosBE
  
 
32 bit:
 
32 bit:
  ../../src/mingw-w64/mingw-w64-headers/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --prefix=/RosBE64
+
  ../../src/mingw-w64/mingw-w64-headers/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --prefix=/RosBE
  
 
Install
 
Install
Line 131: Line 131:
  
 
64 bit:
 
64 bit:
  ../../src/mingw-w64/mingw-w64-crt/configure --prefix=/RosBE64/x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --build=i686-w64-mingw32 --with-sysroot=/RosBE64
+
  ../../src/mingw-w64/mingw-w64-crt/configure --prefix=/RosBE/x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --build=i686-w64-mingw32 --with-sysroot=/RosBE
  
 
32 bit:
 
32 bit:
  ../../src/mingw-w64/mingw-w64-crt/configure --prefix=/RosBE64/i686-w64-mingw32 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --with-sysroot=/RosBE64
+
  ../../src/mingw-w64/mingw-w64-crt/configure --prefix=/RosBE/i686-w64-mingw32 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --with-sysroot=/RosBE
  
 
Compile
 
Compile
Line 142: Line 142:
 
  make install
 
  make install
  
Copy the /RosBE64/x86_64-w64-mingw32 (64 bit) or /RosBE64/i686-w64-mingw32 (32 bit) directory to /RosBE64/mingw.
+
Copy the /RosBE/x86_64-w64-mingw32 (64 bit) or /RosBE/i686-w64-mingw32 (32 bit) directory to /RosBE/mingw.
  
 
=== Building the rest of gcc ===
 
=== Building the rest of gcc ===
Line 159: Line 159:
 
  configure: error: Please check if the mingw-w64 header set and the build/host option are set properly.
 
  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 copied the mingw-headers/include directory to both /RosBE/x86_64-w64-mingw32 and /RosBE/mingw
 
* Check if you have set the PATH variable to the new compiler correctly
 
* 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")
 
* Check if you have installed the new compiler correctly ("make install-gcc")

Revision as of 23:10, 22 April 2019

... 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 ;-)

Setting up the build environment

Download and install MSYS. You will need the following packages:

  • MSYS2 (version 20180531)
  • Recent mingw-w64 32 bit Toolchain (here)

Download all packages and install them into c:\MSYS32. Extract Toolchain to the /usr/ folder inside.

pacman -Syu

pacman -Su

pacman -S make texinfo diffutils

(If installing make makes problems, remove the files it laments about already being existent)

Getting the sources

Download all the sources into subfolders of /src

  • binutils (version 2.32 -> /src/binutils
  • gcc (version 7.4.0 -> /src/gcc
  • mingw-w64 v6.0.0 (here) -> /src/mingw-w64
  • MPFR (version 4.0.2) -> /src/gcc/mpfr
  • GMP (version 6.1.2) -> /src/gcc/gmp
  • MPC (version 1.1.0) -> /src/gcc/mpc

Note

Copy the src/mingw-w64/mingw-w64-headers/include directory to /RosBE/mingw and to /RosBE/x86_64-w64-mingw32 (64 bit) or /RosBE/i686-w64-mingw32 (32 bit).

WARNING!! Might be obsolete. Have to recheck

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 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=/RosBE --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=x86_64-w64-mingw32 --disable-nls --disable-werror --disable-multilib --with-sysroot=/RosBE

32 bit:

../../src/binutils/configure --prefix=/RosBE --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --disable-nls --disable-werror --disable-multilib --with-sysroot=/RosBE

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=/RosBE --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=x86_64-w64-mingw32 --with-pkgversion="RosBE-Windows" --enable-languages=c,c++ --enable-checking=release --disable-win32-registry --disable-shared --disable-nls --disable-werror --disable-multilib --with-sysroot=/RosBE --enable-version-specific-runtime-libs --with-host-libstdcxx="-lstdc++ -lsupc++"

32 bit:

../../src/gcc/configure --prefix=/RosBE --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --with-pkgversion="RosBE-Windows" --enable-languages=c,c++ --enable-checking=release --disable-win32-registry --disable-shared --disable-nls --disable-werror --disable-multilib --with-sysroot=/RosBE --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.

export PATH="$PATH:/RosBE/bin"

Building the mingw-w64 headers

Create a build directory.

cd ..
mkdir mingw-w64-headers
cd mingw-w64-headers

Run the configure script

64 bit:

../../src/mingw-w64/mingw-w64-headers/configure --host=x86_64-w64-mingw32 --build=i686-w64-mingw32 --prefix=/RosBE/x86_64-w64-mingw32

32 bit:

../../src/mingw-w64/mingw-w64-headers/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --prefix=/RosBE/i686-w64-mingw32

Install

make install

Run the configure script

64 bit:

../../src/mingw-w64/mingw-w64-headers/configure --host=x86_64-w64-mingw32 --build=i686-w64-mingw32 --prefix=/RosBE

32 bit:

../../src/mingw-w64/mingw-w64-headers/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --prefix=/RosBE

Install

make install

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=/RosBE/x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --build=i686-w64-mingw32 --with-sysroot=/RosBE

32 bit:

../../src/mingw-w64/mingw-w64-crt/configure --prefix=/RosBE/i686-w64-mingw32 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --with-sysroot=/RosBE

Compile

make

And install

make install

Copy the /RosBE/x86_64-w64-mingw32 (64 bit) or /RosBE/i686-w64-mingw32 (32 bit) directory to /RosBE/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 /RosBE/x86_64-w64-mingw32 and /RosBE/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")