Compiling GCC From Windows
From ReactOS
This page will help guide you through compiling a gnu tool chain in windows for windows. When compiling ReactOS you should always use the ReactOS Build Environment. This is here, mainly, to facilitate rosbe windows updates.
Contents |
Before you start
Needed tools
- MinGW32(gcc 4.4.0 or better)
- hints:
- 1) install normal automated build http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/
- 2) get gcc-base-bin, gcc-base-dll, gcc-c++-bin, gcc-c++-dll, gmp-dll, mpfr-dll, pthreads and extract them to your mingw32 install dir. http://sourceforge.net/projects/mingw/files/GCC%20Version%204/Current%20Release_%20gcc-4.4.0/
- MSYS (be sure to specify mingw32 install location during install) http://sourceforge.net/projects/mingw/files/MSYS%20Base%20System/
- Flex (seems to require msys-regex-1.dll) (extract both packages in your mingw installation directory)
- Perl (only for ppl) (seems to require msys-crypt-0.dll) http://sourceforge.net/projects/mingw/files/MSYS%20perl/
Needed source code
- At least gcc-core and g++ ftp://gcc.gnu.org/pub/gcc/snapshots/
- binutils http://sources-redhat.mirrors.airband.net/binutils/snapshots/
- gmp http://gmplib.org/#DOWNLOAD
- mpfr http://www.mpfr.org/mpfr-current/#download
- winapi package or compatible headers http://sourceforge.net/projects/mingw/files/MinGW%20API%20for%20MS-Windows/
- mingw runtime package http://sourceforge.net/projects/mingw/files/MinGW%20Runtime/
Preparing the source code
You should have, at least, the following directories in your root working directory (in this case C:\source)
Note: Placing the gmp and mpfr package along side gcc, as shown, will cause gcc to compile them automatically, else you will have to configure, make and install them separately.
- binutils
- cloog-ppl(optional)
- gcc
- gmp
- mpfr
- mingw
- mingw-crt
- mingw-headers
At this point we should be ready to start configuring and compiling our toolchain. Fire up the msys prompt, you should check you have gcc, make, flex and all the other tools required before starting.
Configure flags
This document does not and cannot address the meaning of every single configure flag, please check the gcc manual and google for more information. The following flags deserve some explanation.
host/target
The triplet or alias representing the architecture we want to compile for. In our case we are building with host "mingw32" and target "mingw32". See the full list for other options.
prefix
In our case, in the msys environment, the system root is the msys installation directory. With --prefix=C:\rosbe\i586 the "make install" command will put its binaries in "C:\msys\1.0\i386" (assuming standard installation).
Configure and compile
If you're lucky enough, you could copy paste the following code sections into your msys console and get a nice toolchain. ReactOS minimum CPU requirement is pentium.
export CFLAGS="-O2 -mtune=pentium -march=i586" export CXXFLAGS="$CFLAGS" export LDFLAGS=-s
Binutils
cd binutils ./configure --prefix=C:/rosbe/i586 --host=mingw32 --build=mingw32 --target=mingw32 make make install
GCC
cd ../gcc ./configure --prefix=C:/rosbe/i586 --build=mingw32 --host=mingw32 --target=mingw32 --enable-languages=c,c++ \ --disable-win32-registry --enable-sjlj-exceptions --enable-threads=win32 --enable-checking=release make make install
Headers and Runtime
#headers cd ../mingw/w32api cp -R . C:/rosbe/i586/mingw32 #runtime cd ../mingwrt ./configure --prefix=C:/rosbe/i586 --host=mingw32 --build=mingw32 --target=mingw32 make install #symlink cd ../../gcc ln -s C:/rosbe/i586/ winsup
Testing (optional)
Troubleshooting
Cleaning
Sometimes, after and error has occurred, especially if you must go back and change configure settings it is necessary to run these commands:
#delete generated files make clean #delete configure generated files make distclean

