Difference between revisions of "Building MINGW-w64"
Line 83: | Line 83: | ||
== Note == | == Note == | ||
− | Copy the | + | Copy the /RosBE/x86_64-w64-mingw32 (64 bit) or /RosBE/i686-w64-mingw32 (32 bit) directory to /RosBE/mingw. |
+ | |||
+ | Add it to the PATH variable. | ||
+ | export PATH="$PATH:/RosBE/bin" | ||
=== Building gcc-core === | === Building gcc-core === | ||
Line 95: | Line 98: | ||
64 bit: | 64 bit: | ||
− | ../../src/gcc/configure -- | + | ../../src/gcc/configure --target=x86_64-w64-mingw32 --prefix=/RosBE --with-sysroot=/RosBE --with-pkgversion="RosBE-Windows" --enable-languages=c,c++ --enable-fully-dynamic-string --enable-checking=release --enable-version-specific-runtime-libs --enable-plugins --disable-shared --disable-multilib --disable-nls --disable-werror --disable-win32-registry --disable-sjlj-exceptions |
32 bit: | 32 bit: | ||
− | ../../src/gcc/configure -- | + | ../../src/gcc/configure --target=i686-w64-mingw32 --prefix=/RosBE --with-sysroot=/RosBE --with-pkgversion="RosBE-Windows" --enable-languages=c,c++ --enable-fully-dynamic-string --enable-checking=release --enable-version-specific-runtime-libs --enable-plugins --disable-shared --disable-multilib --disable-nls --disable-werror --disable-win32-registry --disable-sjlj-exceptions |
Compile the gcc-core | Compile the gcc-core | ||
Line 105: | Line 108: | ||
And install it | And install it | ||
make install-gcc | make install-gcc | ||
− | + | make install-lto-plugin | |
− | |||
− | |||
=== Building the crt === | === Building the crt === | ||
Line 119: | Line 120: | ||
64 bit: | 64 bit: | ||
− | ../../src/mingw-w64/mingw-w64-crt/configure --prefix=/RosBE/x86_64-w64-mingw32 -- | + | ../../src/mingw-w64/mingw-w64-crt/configure --prefix=/RosBE/x86_64-w64-mingw32 --with-sysroot=/RosBE/x86_64-w64-mingw32 --host=x86_64-w64-mingw32 |
32 bit: | 32 bit: | ||
− | ../../src/mingw-w64/mingw-w64-crt/configure --prefix=/RosBE/i686-w64-mingw32 -- | + | ../../src/mingw-w64/mingw-w64-crt/configure --prefix=/RosBE/i686-w64-mingw32 --with-sysroot=/RosBE/i686-w64-mingw32 --host=i686-w64-mingw32 |
Compile | Compile | ||
Line 129: | Line 130: | ||
And install | And install | ||
make install | make install | ||
− | |||
− | |||
=== Building the rest of gcc === | === Building the rest of gcc === |
Revision as of 19:33, 23 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 ;-)
Contents
Setting up the build environment
Download and install MSYS. You will need the following packages:
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
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 --with-sysroot=/RosBE --target=x86_64-w64-mingw32 --disable-multilib --disable-werror --enable-lto --enable-plugins --with-zlib=yes --disable-nls
32 bit:
../../src/binutils/configure --prefix=/RosBE --with-sysroot=/RosBE --target=i686-w64-mingw32 --disable-multilib --disable-werror --enable-lto --enable-plugins --with-zlib=yes --disable-nls
Now build the whole stuff.
make -jX
Finally install it into the designated directory.
make install
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 --prefix=/RosBE/x86_64-w64-mingw32 --host=x86_64-w64-mingw32
32 bit:
../../src/mingw-w64/mingw-w64-headers/configure --prefix=/RosBE/i686-w64-mingw32 --host=i686-w64-mingw32
Install
make install
Note
Copy the /RosBE/x86_64-w64-mingw32 (64 bit) or /RosBE/i686-w64-mingw32 (32 bit) directory to /RosBE/mingw.
Add it to the PATH variable.
export PATH="$PATH:/RosBE/bin"
Building gcc-core
Enter into the build directory:
cd .. mkdir gcc cd gcc
Now run the configure script:
64 bit:
../../src/gcc/configure --target=x86_64-w64-mingw32 --prefix=/RosBE --with-sysroot=/RosBE --with-pkgversion="RosBE-Windows" --enable-languages=c,c++ --enable-fully-dynamic-string --enable-checking=release --enable-version-specific-runtime-libs --enable-plugins --disable-shared --disable-multilib --disable-nls --disable-werror --disable-win32-registry --disable-sjlj-exceptions
32 bit:
../../src/gcc/configure --target=i686-w64-mingw32 --prefix=/RosBE --with-sysroot=/RosBE --with-pkgversion="RosBE-Windows" --enable-languages=c,c++ --enable-fully-dynamic-string --enable-checking=release --enable-version-specific-runtime-libs --enable-plugins --disable-shared --disable-multilib --disable-nls --disable-werror --disable-win32-registry --disable-sjlj-exceptions
Compile the gcc-core
make all-gcc -jX
And install it
make install-gcc make install-lto-plugin
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 --with-sysroot=/RosBE/x86_64-w64-mingw32 --host=x86_64-w64-mingw32
32 bit:
../../src/mingw-w64/mingw-w64-crt/configure --prefix=/RosBE/i686-w64-mingw32 --with-sysroot=/RosBE/i686-w64-mingw32 --host=i686-w64-mingw32
Compile
make -jX
And install
make install
Building the rest of gcc
Enter into the gcc build directory.
cd .. cd gcc
And compile the rest.
make -jX 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")