Setting Up Mingw Ready for Ruby 1.9.3 Install

This is the first of three posts describing how to install Ruby 1.9.3 native MingW environment. It's much simpler to use Ruby Installer to do this but if you want all the details of how to do it natively, read on…

If you 're wondering why I did this, I wanted to use redcarpet/github-linguist for markdown in Octopress; there's a dependency on the charlock_holmes Gem that requires native code libraries (file, ICU), some of which it needs to build. I couldn't figure out how to make the Ruby Installer do this and I wanted to understand the process, so I did the whole thing from scratch. The second part is here and the final part is here.

This is a prerequisite for installing Ruby 1.9.3 in a native Mingw environment on Windows.

Download and run mingw installer: mingw-get-setup.exe Select 'mingw-developer-toolkit' and apply changes. This installs a default msys and default packages. Start msys.bat (usually in C:\MinGW\msys\1.0).

Edit /etc/fstab to add:

1
2
3
c:/mingw        /mingw
c:/mingw/local32        /local32
c:/mingw/build32        /build32
<!– more –> Create a directory for app install and a build directory (similar to instructions for installing a base system)
1
2
3
4
5
6
mkdir /usr/local
mkdir /usr/local/bin
mkdir /c/mingw/opt
mkdir /c/mingw/build32 /c/mingw/local32
mkdir /c/mingw/opt/bin /local32/{bin,etc,include,lib,share}
mkdir /local32/lib/pkgconfig
Create a profile:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
cat > /local32/etc/profile.local << "EOF"
#
# /local32/etc/profile.local
#

alias dir='ls -la --color=auto'
alias ls='ls --color=auto'

PKG_CONFIG_PATH="/local32/lib/pkgconfig"
CPPFLAGS="-I/local32/include"
CFLAGS="-I/local32/include"
CXXFLAGS="-I/local32/include"
LDFLAGS="-L/local32/lib"
export PKG_CONFIG_PATH CPPFLAGS CFLAGS CXXFLAGS LDFLAGS

PATH="/local32/bin:$PATH"

# package build directory
LOCALBUILDDIR=/build32
# package installation prefix
LOCALDESTDIR=/local32
export LOCALBUILDDIR LOCALDESTDIR

EOF
and a user profile to load it:
1
2
3
4
5
6
cat >> /etc/profile << "EOF"
if [ -f /local32/etc/profile.local ]; then
        source /local32/etc/profile.local
fi

EOF
Remove unwanted automake's (following these Mingw install instructions):
1
mingw-get remove automake1.4 automake1.5 automake1.6 automake1.7 automake1.8
'exit' from all msys shells and restart. You should see the following mounts:
1
2
3
4
5
6
$ mount
...
c:\mingw\build32 on /build32 type user (binmode)
c:\mingw\local32 on /local32 type user (binmode)
c:\mingw on /mingw type user (binmode)
...
Add some additional packages:
1
2
3
mingw-get install base bzip2 expat gcc-g++ gettext gmp libarchive libpdcurses libpopt libunistring lua mingw-utils mpc mpfr pdcurses pkginfo pthreads-w32 zlib

mingw-get install msys-bash msys-bison msys-core-dev msys-crypt msys-cygutils msys-inetutils msys-unzip msys-wget msys-zip  
(optional) Run the mingw installer and mark mingw-tcl and mingw-tk for installation and apply changes. Check they are there:
1
2
cd /mingw
find . -name "tk.h"