Difference between revisions of "Building MINGW-w64"

From ReactOS Wiki
Jump to: navigation, search
(Building gcc-core)
(Getting the sources)
Line 25: Line 25:
 
Download all the sources into subfolders of /home/YourName/src
 
Download all the sources into subfolders of /home/YourName/src
  
* binutils-2.20.1-src.tar.gz -> home/YourName/src/binutils
+
* binutils (version 2.20.51 or newer) -> home/YourName/src/binutils
 
* gcc-core + gcc-g++ -> home/YourName/src/gcc
 
* gcc-core + gcc-g++ -> home/YourName/src/gcc
 
* mingw-w64 -> home/YourName/src/mingw-w64
 
* mingw-w64 -> home/YourName/src/mingw-w64

Revision as of 01:00, 9 April 2010

... 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:

  • binutils-2.20.1-2-mingw32-bin.tar.gz
  • bison-2.4.1-1-msys-1.0.11-bin.tar.lzma
  • coreutils-5.97-2-msys-1.0.11-bin.tar.lzma
  • flex-2.5.35-1-msys-1.0.11-bin.tar.lzma
  • gettext-0.17-1-mingw32-dev.tar.lzma
  • grep-2.5.4-1-msys-1.0.11-bin.tar.lzma
  • sed-4.2.1-1-msys-1.0.11-bin.tar.lzma

...


Download all packages and extract them into c:\MSYS (or similar). You can unpack the .tar.lzma files using the latest version of 7zip.

Extract the following archive into the mingw subfolder of the MSYS root (Why? Because!):

  • libiconv-1.13.1-1-mingw32-dev.tar.lzma

Getting the sources

Download all the sources into subfolders of /home/YourName/src

  • binutils (version 2.20.51 or newer) -> home/YourName/src/binutils
  • gcc-core + gcc-g++ -> home/YourName/src/gcc
  • mingw-w64 -> home/YourName/src/mingw-w64

Copy the src/mingw-w64/mingw-w64-headers/include directory to /RosBE64/mingw and to /RosBE64/x86_64-w64-mingw32

Patching the sources

You need to do 2 small modifications to build the libraries properly without leading underscores. This part is subject to change anytime soon.

  • Open src/gcc/config/mh-mingw and add the follwing 3 lines:
CFLAGS_FOR_TARGET += -fno-leading-underscore
CXXFLAGS_FOR_TARGET += -fno-leading-underscore
  • Open mingw-w64/minw-w64-crt/makefile.in and change the following

change

DLLTOOL = @DLLTOOL@

into

DLLTOOL = x86_64-w64-mingw32-dlltool

and

AM_CFLAGS = -pipe $(vistasupport) -std=gnu99 @ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@
AM_CXXFLAGS = @ADD_C_CXX_WARNING_FLAGS@ @ADD_CXX_ONLY_WARNING_FLAGS@
AM_DLLTOOLFLAGS = -k --as=$(AS) --output-lib $@

into

AM_CFLAGS = -fno-leading-underscore -pipe $(vistasupport) -std=gnu99 @ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@
AM_CXXFLAGS = -fno-leading-underscore @ADD_C_CXX_WARNING_FLAGS@ @ADD_CXX_ONLY_WARNING_FLAGS@
AM_DLLTOOLFLAGS = --no-leading-underscore -k --as=$(AS) --output-lib $@

Building

Building binutils

Create a build subdirectory for binutils:

cd build
mkdir binutils
cd binutils

From the build directory run the binutils configure script:

../../src/binutils/configure --target=x86_64-w64-mingw32 --prefix=/RosBE64 --with-sysroot=/RosBE64 
 --disable-multilib

Now build the whole stuff.

make

Finally install it into the designated directory.

make install

Building gcc-core

Emter into the build directory:

cd ..
mkdir gcc
cd gcc

Now run the configure script:

../../src/gcc/configure --target=x86_64-w64-mingw32 --prefix=/RosBE64 --with-sysroot=/RosBE64 
 --disable-multilib --disable-shared

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

../../src/mingw-w64/mingw-w64-crt/configure --host=x86_64-w64-mingw32 --prefix=/RosBE64 --with-sysroot=/RosBE64

Compile

make

And install

make install

Building the rest of gcc

Enter into the gcc build directory.

cd ..
cd gcc

And compile the rest.

make
make install