[SPAM] I'm a newbie to MinGW. How Can I build MinGW from source?

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: I'm a newbie to MinGW. How Can I build MinGW from source?

Ranger
This post was updated on .
Thanks for Keith,I'm just a copycat. ;)
I copy the steps that build gcc-5.3 cross compiler as follow:

build enviroment:
os: ubuntu x86(i386) 14.10
gcc version: 4.9.1
gcc source version: 5.3

mingw32 build steps:
1) download source:
from sourceforge's mingw project:
  mingwrt-5.0 preview snapshot
  w32api-5.0 preview snapshot
  gcc-5.3.0 (distributed by MinGW.org)
from GNU mirror:
  binutils-2.26
  gmp-6.1.0
  mpfr-3.1.3
  mpc-1.0.2

2) make dirs:
$ cd $HOME
$ mkdir -p $HOME/mingw32-src/build/{binutils,gcc,mingwrt,w32api}
$ mkdir $HOME/mingw32-gcc-sandbox
$ ln -fs mingw32-gcc-sandbox mingw32
$ cd $HOME/mingw32
$ ln -s . mingw

3)prepare source:
unpack downloaded source packages to $HOME/mingw32-src.
$ cd $HOME/mingw32-src/gcc-5.3.0
$ ln -s ../gmp-6.1.0 gmp
$ ln -s ../mpfr-3.1.3 mpfr
$ ln -s ../mpc-1.0.2 mpc

4)export PATH:
$ export PATH=$PATH:$HOME/mingw32/bin

5)install mingw-pkg tool:
download mingw-pkg snapshot from https://sourceforge.net/u/keithmarshall/mingw-pkg/ci/master/tree/

unpack downloaded mingw-pkg,configure,make and make install mingw-pkg. You can get information form this thread:
https://sourceforge.net/p/mingw/mailman/message/35573728/

If you get error: sh: ../configure: No such file or directory.
No panic, just get autoconf installed( form ubuntu packages or get source form gnu and install).

6)mingwrt (just headers):
$ cd $HOME/mingw32-src/build/mingwrt
$ ../../mingwrt-5.0/configure --build=unknown --host=mingw32 --prefix=$HOME/mingw32
$ make install-headers

7)w32api (just headers):
$ cd ../w32api
$ ../../w32api-5.0/configure --build=unknown --host=mingw32 --prefix=$HOME/mingw32
$ make install-headers

8)binutils:
$ cd ../binutils
$ ../../binutils-2.26/configure --target=mingw32 --{prefix,with-sysroot}=$HOME/mingw32 --disable-nls
$ make
$ make install

9)gcc: stage-1 build
$ cd $HOME/mingw32-src/gcc-5.3.0
$ mingw-pkg patch
$ cd $HOME/mingw32-src/build/gcc
$ ../../gcc-5.3.0/configure --{prefix,with-sysroot}=$HOME/mingw32 \
     --target=mingw32 --with-arch=i586 --with-tune=generic \
     --enable-shared --enable-threads --disable-win32-registry \
     --disable-sjlj-exceptions --disable-multilib --disable-nls \
     --disable-libvtv --with-dwarf2 --enable-languages=c,c++
$ make all-gcc && make install-gcc

10)gcc: check
make sure we can access it via $PATH
$ which mingw32-gcc
/home/www/mingw32/bin/mingw32-gcc

Here terminal display message should be different: /home/**/mingw32/bin/mingw32-gcc   (** is your login account if you logined with nonroot)

$ mingw32-gcc --version
  mingw32-gcc (GCC) 5.3.0
  Copyright (C) 2015 Free Software Foundation, Inc.

11)mingwrt:
$ cd ../mingwrt
$ ./config.status --recheck
$ ./config.status
$ make
$ make install

12)w32api:
$ cd ../w32api
$ ./config.status --recheck
$ ./config.status
$ make
$ make install

13)gcc: stage-2 build
$ cd ../gcc
$ make all
$ make instal

If you get some error like awk, get and install ubuntu gawk package.
If you get some error like m4, get and install ubuntu m4 package.
If you get error: 'wcstof' is not a member of 'std', you can apply the workaround provided by keith:
https://sourceforge.net/p/mingw/mingw-org-wsl/ci/617f15b16863cb5d542d1134e44e8fbd72739ad4/

Now we get building work done. Enjoy it!
Next, I'll move on and try to build windows-host ARM toolchain according to Keith's advice.

Best regards.
Wang LingJun
12