Page 1 of 1

Installing MinGW and MSYS in Windows 7 or Vista

Posted: Thu Jan 21, 2010 6:37 pm
by ragnarok2040
Because there's an idiot at Microsoft, Vista and 7 have something called installer detection. It essentially requires admin rights to run an installer, which escalates the installer's privileges to admin level, inherently making the whole idea worthless as that does exactly what malware wants you to do. There are ways to bypass the detection using a manifest or turning off UAC but it's not really worth it. Sometimes renaming the installers work, but it didn't work for me in this case.

In order to install mingw/msys under your own user privileges, you'll have to do the install by hand.

Programs needed:
  • 7zip or another archive manager able to extract gzipped tarballs.
Packages needed:
  • MinGW:
    binutils-2.20-1-mingw32-bin.tar.gz
    gcc-core-3.4.5-20060117-3.tar.gz
    gcc-g++-3.4.5-20060117-3.tar.gz
    mingwrt-3.17-mingw32-dev.tar.gz
    mingwrt-3.17-mingw32-dll.tar.gz
    w32api-3.14-mingw32-dev.tar.gz

    MSYS:
    msysCORE-1.0.11-bin.tar.gz
Installing MinGW/MSYS:
  • 1) Make a mingw directory somewhere. I used C:\Users\<username>\mingw as my mingw directory. No spaces.
    2) Extract each mingw package and copy their files into that directory making sure the directories match up and are merged.
    3) Make a msys directory inside that mingw directory.
    4) Extract the msysCORE package into that directory. There's a toplevel "." directory that might exist, make sure it's not mingw/msys/./bin and that it's mingw/msys/bin
    5) Run the pi.bat file inside the mingw/msys/postinstall directory.
    6) Important: After typing in the path to mingw, if it doesn't detect the mingw installation, then you'll need to modify the fstab manually.
    7) The fstab file should have a single line consisting of the path to your mingw directory as c:/Users/<username>/mingw or c:/mingw and a msys mountpoint that's /mingw.

    Code: Select all

    c&#58;/Users/<username>/mingw /mingw
    
    8) Make a shortcut of mingw/msys/msys.bat to your Desktop if you want.

Compiling and Installing Binutils

Posted: Fri Jan 22, 2010 1:48 pm
by ragnarok2040
Compiling the toolchain on Windows 7 and Vista doesn't work as smoothly as it does on XP. The ps2dev-patches I provide have support for the DESTDIR variable when doing a "make install" command. For those not in the know, it allows you to make a mirror image install to any directory not just the prefix directory. The prefix path is still hardcoded into the binaries, though. It's just an easy way to package binaries.

Programs needed:
  • Codeblocks or other editor that can edit files using LF line endings.
Configuring Codeblocks' Editor:
  • 1) Turn on "Show end of line chars"
    2) Turn off the "Strip trailing blanks"
    3) Change "End-of-line mode" to LF.
Packages needed:
  • ps2dev-patches.tar.gz or here
    binutils-2.14.tar.gz or binutils-2.14.tar.bz2
    gcc-3.2.2.tar.gz or gcc-3.2.2.tar.bz2
    newlib-1.10.0.tar.gz or newlib-1.10.0.tar.bz2
Preparation:
  • 1) Open MSYS.
    2) Type: mkdir ps2dev
    3) Copy the packages to that directory.
    4) Extract ps2dev-patches.tar.gz using tar.
Compiling binutils:
  • 1) Open MSYS.
    2) Type: cd ~/ps2dev
    3) Type: mkdir ps2-binutils ee-binutils iop-binutils dvp-binutils
    4) Extract the binutils-2.14 tarball using tar.
    5) Type: patch -p0 < ps2dev-patches/binutils-2.14-PS2.patch
    6) Type: patch -p0 < ps2dev-patches/binutils-destdir.patch
    7) For each target, ee, iop, dvp:
    • a) Type: cd <target>-binutils
      b) Type: CFLAGS="-O0 -std=c99 -D__USE_MINGW_ACCESS" ../binutils-2.14/configure --prefix=/opt/ps2dev/<target> --target=<target>
      c) open binutils-2.14/intl/Makefile.in to remove the ":." from the aliaspath variable (may need to preserve line endings and whitespace so don't use notepad or wordpad)
      d) Type: CFLAGS="-O0 -std=c99 -D__USE_MINGW_ACCESS" make clean
      e) Type: CFLAGS="-O0 -std=c99 -D__USE_MINGW_ACCESS" make
      f) Type: CFLAGS="-O0 -std=c99 -D__USE_MINGW_ACCESS" make -j1 DESTDIR=/home/<username>/ps2dev/ps2-binutils install
    8) Type: cd ~/ps2dev
    9) Type: tar cfz ps2-binutils.tar.gz ps2-binutils
    10) Type: cd ps2-binutils && cp -i -r opt /
Now you have a backup of your ps2 binutils ready to be reinstalled at any time, to the same directory within Windows, and a copy is installed at "/opt/ps2dev". You can remove all the build directories and the ps2-binutils directory now.

Compiling and Installing ee-gcc and iop-gcc

Posted: Fri Jan 22, 2010 1:52 pm
by ragnarok2040
Warning: Be careful when typing commands. I use both opt/ps2dev and /opt/ps2dev, the first being the directory in the current directory, and the second being the directory located in the root / directory.

Note: The removal of libiberty.a and ee-c++filt.exe from gcc are because the versions built by binutils-2.14 are newer and they create conflicts when installing the toolchain from the archives.

Compiling GCC:
  • 1) Open MSYS
    2) Type: cd ~/ps2dev
    3) Type: export PATH=$PATH:/opt/ps2dev/ee/bin:/opt/ps2dev/iop/bin
    4) Type: mkdir ee-gcc ee-gcc-bin iop-gcc-bin iop-gcc
    5) Extract the gcc-3.2.2 tarball using tar
    6) Type: patch -p0 < ps2dev-patches/gcc-3.2.2-PS2.patch
    7) For each target, ee and iop:
    • a) Type: cd <target>-gcc
      b) Type: CFLAGS="-std=c99 -D__USE_MINGW_ACCESS" ../gcc-3.2.2/configure --prefix=/opt/ps2dev/<target> --target=<target> --enable-languages="c" --with-newlib --without-headers
      c) Type: CFLAGS="-std=c99 -D__USE_MINGW_ACCESS" make clean
      d) Type: CFLAGS="-std=c99 -D__USE_MINGW_ACCESS" make
      e) Type: CFLAGS="-std=c99 -D__USE_MINGW_ACCESS" make -j1 DESTDIR=/home/<username>/ps2dev/<target>-gcc-bin install
    8) Type: cd ..
    9) Optional: Remove any sys-include directories made from the configure script in /opt/ps2dev/<target>/<target>
    10) Type: rm ee-gcc/opt/ps2dev/ee/lib/libiberty.a
    11) Type: rm iop-gcc/opt/ps2dev/iop/lib/libiberty.a
    12) Type: tar cfz iop-gcc-bin.tar.gz iop-gcc-bin
    13) Type: cd ee-gcc-bin && cp -i -r opt / && cd ..
    14) Type: cd iop-gcc-bin && cp -i -r opt / && cd ..
    15) Remove the ee-gcc and ee-gcc-bin directories
Now iop-gcc is built and archived and the ee-gcc base is built to build newlib.

Compiling ee-newlib:
  • 1) Open MSYS
    2) Type: cd ~/ps2dev
    3) Type: export PATH=$PATH:/opt/ps2dev/ee/bin
    4) Extract the newlib-1.10.0 tarball using tar
    5) Type: patch -p0 < ps2dev-patches/newlib-1.10.0-PS2.patch
    6) Type: mkdir ee-newlib ee-newlib-bin
    7) Type: cd ee-newlib
    8) Type: ../newlib-1.10.0/configure --prefix=/opt/ps2dev/ee --target=ee
    9) Type: CPPFLAGS="-G0" make clean
    10) Type: CPPFLAGS="-G0" make
    11) Type: CPPFLAGS="-G0" make -j1 DESTDIR=/home/<username>/ps2dev/ee-newlib-bin install
    12) Type: cd ..
    13) Type: tar cfz ee-newlib-bin.tar.gz ee-newlib-bin
    14) Type: cd ee-newlib-bin && cp -i -r opt /
Compiling ee-gcc:
  • 1) Open MSYS
    2) Type: cd ~/ps2dev
    3) Type: mkdir ee-gcc-bin ee-gcc
    4) Type: export PATH=$PATH:/opt/ps2dev/ee/bin
    5) Type: cd ee-gcc
    6) Type: CFLAGS="-std=c99 -D__USE_MINGW_ACCESS" ../gcc-3.2.2/configure --prefix=/opt/ps2dev/ee --target=ee --enable-languages="c,c++" --with-newlib --with-headers=/opt/ps2dev/ee/ee/include --enable-cxx-flags="-G0"
    7) Type: CFLAGS="-std=c99 -D__USE_MINGW_ACCESS" CFLAGS_FOR_TARGET="-G0" make clean
    8) Type: CFLAGS="-std=c99 -D__USE_MINGW_ACCESS" CFLAGS_FOR_TARGET="-G0" make
    9) Type: CFLAGS="-std=c99 -D__USE_MINGW_ACCESS" CFLAGS_FOR_TARGET="-G0" make -j1 DESTDIR=/home/<username>/ps2dev/ee-gcc-bin install
    10) Type: cd ../ee-gcc-bin
    11) Type: rm opt/ps2dev/ee/bin/ee-c++filt.exe
    12) Type: rm opt/ps2dev/ee/lib/libiberty.a
    13) Type: cd ..
    14) Type: tar cfz ee-gcc-bin.tar.gz ee-gcc-bin
    15) Type: cd ee-gcc-bin && cp -i -r opt /
That should be it. You should have 4 archives called ps2-binutils.tar.gz, iop-gcc-bin.tar.gz, ee-newlib-bin.tar.gz, and ee-gcc-bin.tar.gz. I usually remove /opt/ps2dev and install the binaries from the archives at this point by extracting, changing directory to the extracted files, and doing "cp -i -r opt /". The "cp -i -r" command will notify of any file conflicts when installing the toolchain from the archives, but there shouldn't be any as all conflicting files between the archives were removed. Remember that the binaries aren't portable and use Windows absolute paths when they were compiled(even in MSYS), so you can't install them to a different Windows path.

Remember to modify the PATH variable at the bottom of /etc/profile to include the bin directories of the toolchains.

Code: Select all

PATH=$PATH&#58;/opt/ps2dev/ee/bin&#58;/opt/ps2dev/iop/bin&#58;/opt/ps2dev/dvp/bin
PS2DEV=/opt/ps2dev
I made this tutorial because I had to compile the toolchain on Vista. I tried Cygwin 1.7.1, but it was slow (3x-5x slower than MinGW), and there seems to be an issue with the newlib headers or system headers in regards to building gcc with g++. The only bug report I found referenced a misconfiguration with kernel-headers on Linux. I think that's it, but if I missed a step or made a typo or there are problems, let me know :D.

Posted: Sun Jan 24, 2010 10:38 am
by jgrimm
you know you can download the Windows XP Mode if you have windows 7 and install the compiler on it. Windows XP Mode is just virtual pc that comes with a preinstalled windows xp image

Posted: Sun Jan 24, 2010 11:39 pm
by ragnarok2040
The WinXP Mode is only for Windows 7 Professional or above. For the other versions of 7 or any version of Vista, you would need a license for XP and would have to manually install XP into a vm.

For 64-bit versions of Windows, you probably would need to use a 32-bit Windows vm, or use a Linux vm. I haven't tried mingw-w64.

For 32-bit versions of Windows, the new commandline terminal in Windows Vista and 7 seems to be more compatible with MSYS than XP's terminal. At least, there weren't any "Cannot find file 'c:ps2deveeeebinnm.exe'" warnings or errors from '/' or '\''s getting eaten.

For a Linux vm, I prefer ArchLinux myself because of the Automated Build System and pacman, which makes installing from source simpler than even a Windows installer albeit that you have to type two commands to build and install packages. After that, it's just a single command to uninstall or reinstall each package. That's why I added DESTDIR support for rolling binary packages.