Skip to content

Msys2 and Shoes for Windows

Cecil edited this page Dec 11, 2017 · 1 revision

Msys2 And Shoes

This is likely to be the preferred way to build Shoes, Ruby and anything they might need on Windows. Msys2 is a fairly complete implementation of a Linux a commandline - with some odd twists. Download instructions . You'll want 20GB of disk space to be safe.

Msys2 Layout

There are 3 shells you can start and they set the $PATH differently. One for msys2 internals - you don't that want that one and one for build 64 bit things. We don't want that one either because Shoes and Ruby on Windows is easier on 32 bits. So after Msys2 is installed then open that 32 bit shell.

In that 32 bit shell we need to install all kinds of packages (aka dependencies) and Msys2 has pacman which makes this easy. Beware you're going to get the latest of everything, and like homebrew on OSX that may not be what you want for older system compatibility. We'll see if we like that situation.

Remember, you want to be in the Msys 32 bit Shell!

# toolchain
pacman -S mingw-w64-i686-binutils mingw-w64-i686-gcc mingw-w64-i686-gdb
# make and Autotools
pacman -S make pkgconfig autoconf automake libtool intltool patch
# Please install git (again) and bison (used by Ruby)
pacman -S git bison vim nano
# because I want it:
pacman -S rsync

Paths

Msys2 has an slightly odd layout for Linux people. The main location is C:\msys64 or '/msys64' if your in the shell. You want to remember that. Inside are what you would expect to see in a Linux root or '/'. Things like dev/ and /usr - wait there is no lib/ or bin/ or /include. That's not normal. Magic is in the /msys64/mingw32/ directory

Paths take many forms: Windows, msys2 and Ruby/rake each has it's own way of dealing with Windows paths. This complicates things mightily in building Shoes. I can't fix it. You can't fix it. We can only adjust to it.

Pre-built dependencies

This is the easiest way to get started because you can most ignore of the lengthly work. You still have to learn some things that might not be obvious. You'll need a few GB of disk space. First we download a huge 47MB tar.gz of dependenent libraries, then a slightly smaller 14MB Ruby that requires the big one. Then we expand them and build Shoes.

Sandboxes

I prefer to (have to, really) build all Ruby and Shoes dependent libraries myself. This is a time consuming pain in the behind but it's not hard, just tedious - we have scripts to do each. These libraries are outside of msys2 and pacman's knowledge or control. I like having ruby in another sandbox you it can updated later without changing everything else. My main sandbox is C:\shoesdeps (aka /c/shoesdeps/ - for _most _things). and I'm going to have directories in there: mingw, ruby-2.2.6, gems, and src. src will be downloaded and expanded tar balls with the configure scripts in there. mingw will contain most of low level stuff. Ruby will them and Shoes use both of them

Ruby Dependencies

We need a Ruby that we can copy into Shoes and to run the build process and at the moment that is ruby 2.2.6. Msys2/Pacman only supplies ruby 2.4 and we can't use that new a version. So, we have to build from source. If we can do this we can build almost anything we might need.

Sadly, Ruby has dependent libraries too and msys2/pacman doesn't always do the right thing. We first need to build the ruby dependencies We need to build yaml, gdbm, gmp, ffi, openssl. We may need to patch one or more of them to be msys2 friendly.

libz - 1.2.8

This needs to be done first because lots of things use it. We will start a pattern of creating a configure script, downloading, running the confiure and make, make install. With variations of the general pattern. Zlib is the first divergence. Create msys2-zlib.sh in yoursrc directory.

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export INCLUDE_PATH=${dest}/include
export LIBRARY_PATH=${dest}/lib
export BINARY_PATH=${dest}/bin
make -fwin32/Makefile.gcc
make install -fwin32/Makefile.gcc SHARED_MODE=1

Now, lets download it, expand it, configure a make and install it.

wget http://zlib.net/zlib-1.2.8.tar.xz
tar xf zlib-1.2.8.tar.xz
cd zlib-1.2.8
../msys2-zlib.sh

You should have zlib1.dll in your deps bin/ (/c/shoesdeps/mingw/bin).

yaml 0.1.7

Create a msys2-yaml.sh in your src directory. Mine looks like:

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-DYAML_DECLARE_EXPORT -I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
  --enable-shared \
  --prefix="$dest"

Yaml needs a patch and the patch happens to require some extra jiggery.

wget http://pyyaml.org/download/libyaml/yaml-0.1.7.tar.gz
wget https://walkabout.mvmanila.com/public/patch/msys2/yaml.patch
tar xf yaml-0.1.7.tar.gz
cd yaml-0.1.7
patch -p1 <../yaml.patch
autoreconf -fvi

We're still in the yaml-0.1.7 directory so we configure with a

../msys2-yaml.sh

Configure takes a while to run and is chatty. Get used to it. If it doesn't tell you about an error at the end then we can proceed to build and install it in msys2.

make
make install

Both make and make install will complain and stop when something is not right. Do not assume that just repeating will fix anything. Let's cd .. up to our shoesdeps/src. Check to make sure you have libyaml-0-2.dll where in your mingw/bin directory.

For the curious, the patch allows building a dll if you define (-DYAML_DECLARE_EXPORT) which is something Shoes really, really needs.

gdbm 1.1.12

Another patch, sigh. So, get back to that src directory and create a msys2-gdbm.sh script:

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
  --enable-shared \
  --prefix=${dest}

Then you can do

wget ftp://ftp.gnu.org/gnu/gdbm/gdbm-1.12.tar.gz
wget https://walkabout.mvmanila.com/public/patch/msys2/gdbm.patch
tar xf gdbm-1.12.tar.gz
cd gdbm-1.12.tar.gz
patch -p1 <../yaml.patch
../msys2-gdbm.sh
make
make install

You should check that the dlls end up where you expect them (/c/shoesdepe/mingw/bin for me)

gmp 6.1.0.

The multi-precision library is new with ruby 2.2.6 and it may be used by openssl (below). This takes some time to compile and insists on running it tests which takes even more time. Remember. suffering makes you virtuous. Your msys2-gmp script:

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
  --enable-shared \
  --disable-static \
  --prefix="$dest"

You know the drill. You may want to use 6.1.12 - your risk.

wget https://gmplib.org/download/gmp/gmp-6.1.0.tar.xz
tar xf gmp-6.1.0.tar.xz
cd gmp-6.1.0
../msys2-gmp.sh
make
make test # or make check or whatever it tells you to do. Take a break.
make install

ffi wants to put its .h files in lib/libffi-3.2.1/include instead of include/ No doubt the authors had their reasons but it's kind of confusing to me. There is a patch here which I'm going to use. Note: we'll have edit the .pc file after we install it - the patch is incomplete. So, in libffi-3.2.1 dir do

patch -p1 <../ffi.patch

msys2-ffi.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
  --prefix=${dest}

and then configure, make, make install

cd libffi-3.2.1
../msys2-ffi.sh
make
make install

Check that the dll is where it should be. If you used the patch you need to edit /c/shoesdeps/mingw/lib/pkgconfig/ so it looks like this:

 more /c/shoesdeps/mingw/lib/pkgconfig/libffi.pc
prefix=/c/shoesdeps/mingw
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
toolexeclibdir=${exec_prefix}/lib/../lib
includedir=${exec_prefix}/include

Name: libffi
Description: Library supporting Foreign Function Interfaces
Version: 3.2.1
Libs: -L${toolexeclibdir} -lffi
Cflags: -I${includedir}

Of course, if you put shoesdeps on e: or named it something else you'd want to fix that prefix line.

openssl 1.0.2k

This is a tiny bit different. Create your msys2-openssl.sh script:

#! /bin/bash
# execute it instead of ./Configure
export dest=/c/shoesdeps/mingw
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./Configure \
   mingw zlib-dynamic shared \
  -I${dest}/include \
  --prefix="${dest}"

And - take a break while this runs.

wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz
tar xf openssl-1.0.2k.tar.gz
cd openssl-1.0.2k
../msys2-openssl.sh
make
make install

do you have libeay32.dll and ssleay32.dll ?

Building Ruby 2.2.7

Time to build Ruby 2.2.7 - We want it to only use the libraries (deps) in our general sandbox (/c/shoesdeps for me). We also want our ruby to be in different sandbox.

mkdir -p /c/shoedeps/ruby-2.2.7

Be in the shoesdeps/src directory and create an msys2-ruby.sh that looks like

msys2-ruby.sh

#! /bin/bash
# execute it instead of ./configure
export dest="C:/shoesdeps/ruby-2.2.7"
export deps="/c/shoesdeps/mingw"
export LDFLAGS="-L${deps}/lib"
export CFLAGS="-I{deps}/include"
./configure \
  --enable-shared \
  --enable-load-relative \
  --disable-install-doc \
  --without-tk --without-tcllib --without-tcltk \
  --prefix=${dest}

In the shoesdeps/src directory, we download the ruby source a and patch, expand it, cd inside apply the patch and configure.

wget https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.7.tar.gz
wget https://walkabout.mvmanila.com/public/patch/msys2/ruby.patch
tar xf ruby-2.2.7.tar.gz
cd ruby-2.2.7
patch -p1 <../ruby.patch
../msys2-ruby.sh

This configure takes a few minutes. Some people might want to save the terminal output to a file. if it ends like

checking for awf... no
.ext/include/i386-mingw32/ruby/config.h updated
ruby library version = 2.2.0
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating Makefile
config.status: creating ruby-2.2.pc

You're good for the next lengthy step - compiling ruby. Be patient. I like to do clear; clear; make here so the terminal has only this step's output, because I might want to save it or study it. Basically, it's going to compile some base ruby stuff and then it's going to check if you have some dlls so it can configure the build of some standard library routines Those 'configuring' messages are important to you. It would be normal for 'dbm' not to configure as well as a pty and syslog because Windows just can't do that. Openssl and socket take a long time. Then the build compiles those configured things and then compiles character set handlers -- there are many.

If you think it is good, (no error you haven't be warned about) let's install into the sandbox. clear; clear; make install. Life could be good if you get

installing default gems:      C:/msys64/home/Cecil/shoesdeps/ruby-2.2.6/lib/ruby/gems/2.2.0 (build_info, cache, doc, extensions, gems, specifications)
                              bigdecimal 1.2.6
                              io-console 0.4.3
                              json 1.8.1
                              psych 2.0.8
                              rake 10.4.2
                              rdoc 4.2.0
installing bundle gems:       C:/msys64/home/Cecil/shoesdeps/ruby-2.2.6/lib/ruby/gems/2.2.0 (build_info, cache, doc, extensions, gems, specifications)
                              minitest-5.4.3.gem
                              power_assert-0.2.2.gem
                              test-unit-3.0.8.gem
$

set $PATH

We need to put our new Ruby ahead of anything that might be installed by Msys2. We installed the vim and nano above So cd to your msys2 home msys dirctory and edit the ~/.bash_profile. At the bottom, you'll want something like this and save it.

#PS1='\[\e[1;32m\]\u:\[\e[1;34\]\w \$ \e[0m'
#PS1='\u@\h \e[1;34m\]\w:$ \e[0m'
export PATH="/c/shoesdeps/ruby-2.2.7/bin:/c/shoesdeps/mingw/bin:$PATH"
export EDITOR=/usr/bin/vim
set -o noclobber

You will need to open a new shell window to see the effect or you can do a `source ~/.bash_profile' to refresh your shell settings. That PS1 setting is what I like, you can do what you like. That's a cosmetic thing. The important point is to prepend our ruby/bin directory to the $PATH.

Test:

$ ruby -v
ruby 2.2.6p396 (2016-11-15 revision 56800) [i386-mingw32]

update the gem handling

Ruby never comes with the latest version of rubygems and I prefer to use something more current so download a newer rubygems ( 2.6.10 at this moment).

wget https://rubygems.org/rubygems/rubygems-2.6.10.tgz
tar xf rubygems-2.6.10.tgz
cd rubygems-2.6.10
ruby setup.rb --no-dococument

Test it (the setup creates a gem command but your can use gem.bat if so inclined. I don't like typing .bat and we will fix rake/rake.bat later.

gem -v
2.6.10
gem list -l

Less bat, more better.

For linux or osx folks, typing rake.bat just feels wrong. We can fix it by copying the rake script from a unix ruby

cd /c/shoesdeps/ruby-2.2.6//bin/
Cecil@bronco7:~/shoesdeps/ruby-2.2.6/bin$ ls
erb.bat  gem.bat  msvcrt-ruby220.dll  rdoc.bat  ruby.exe
gem      irb.bat  rake.bat            ri.bat    rubyw.exe

Since our Ruby wasn't build with ri or rdoc you could delete those bat files. Your Cosmetic choice.

rake

For linux or osx folks, typing rake.bat just feels wrong. We can fix it by copying the rake script from a unix ruby or you could ignore the oss copyright and create a file named rake (no extension) with the following

#!/usr/bin/env ruby
begin
  require 'rubygems'
  gem 'rake'
rescue LoadError
end
require 'rake'
Rake.application.run

irb

Sadly, the following doesn't work. You'll have to use irb.bat

#!/usr/bin/env ruby
require "irb"

IRB.start(__FILE__)

Build Gtk and friends

This going to take some time unless you can find some prebuilt libraries -not available yet. We going to use the familiar pattern. cd in /c/shoesdeps/src, download the file and any patches , expand the tar, cd into the directory run the optional path, run the config script, make, make install. I'm only going show the configure script from now on with comments on less obvious things. Most of these have to be built in the order given. We'll start with a couple of easier ones, libpng and libjpeg. BTW, if you want to know what other options are possible do ./configure --help It would not be wise to change them without knowledge - other that editing the dest var to point to your deps lib.

#! /bin/bash7 /c/shoesdeps/src/libpng-1.6.28:$ more ../msys2-png.sh
# execute it instead of ./configure
export dest=/c/shoesdeps/mingw
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_PATH=${dest}/lib/pkgconfig
./configure \
  --prefix=${dest}
#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
  --prefix=${dest}
#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
  --prefix=${dest}

This one can take a while to configure.

# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
  --with-zlib=${dest} \
  --without-python \
  --prefix=${dest}

Without python means we aren't going to create python bindings - which we couldn't use anyway. Note: this uses that iconv we built.

glib-2.50.2

Takes a while.

#! /bin/bash
# execute this instead of ./configure
export dest=/c/shoesdeps/mingw
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig"
#export LIBFFI_CFLAGS="-I${dest}/lib/libffi-3.2.1/include"
./configure \
  --with-pcre=internal \
  --cache-file=win32.cache \
  --with-threads=win32 \
  --prefix="${dest}"

If you're wondering about that --with-thread setting - me too!

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig"
./configure \
  --prefix=${dest}

NOTE: building this from source fails. Even when using the the msys2 patches. It's also a very slow process. So skip to the next library to build, we'll deal with it later. libintl requires libiconv4 (plus the normal Windows stuff) so we'll deal with that later.

This will take some time and patches. Lots and lots of time and patches. If you think building Ruby was slow, this will change that belief! Lets download the patches into our src directory - we'll change the name for less clutter and to be in the order that pacman uses.

wget -O gettext.patch.1 https://raw.githubusercontent.com/Alexpux/MSYS2-packages/master/gettext/0.18.1.1-autopoint-V.patch
wget -O gettext.patch.2 https://raw.githubusercontent.com/Alexpux/MSYS2-packages/master/gettext/0.19.3-localename.patch
wget -O gettext.patch.3 https://raw.githubusercontent.com/Alexpux/MSYS2-packages/master/gettext/0.18.1.1-no-woe32dll.patch
wget -O gettext.patch.4 https://raw.githubusercontent.com/Alexpux/MSYS2-packages/master/gettext/0.19.3-tests-cygwin.patch
wget -O gettext.patch.5 https://raw.githubusercontent.com/Alexpux/MSYS2-packages/master/gettext/gettext-0.18.3.1-msys2.patch
wget -O gettext.patch.6 https://raw.githubusercontent.com/Alexpux/MSYS2-packages/master/gettext/gettext-0.19.7-archive.patch

"Today, we patch!" Pay attention -pn varies. If patch complains and rejects, you have a problem to solve!

tar xf gettext-0.19.8.tar.xz;
cd gettext-0.19.8
patch -p2 <../gettext.patch.1
patch -p2 <../gettext.patch.2
patch -p2 <../gettext.patch.3
patch -p2 <../gettext.patch.4
FAIL!
#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig"
./configure \
  --prefix=${dest}
#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig"
./configure \
  --prefix=${dest}
#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig"
./configure \
  --prefix=${dest}

Funny Font Farm

Evidently, some newer fonts could be bzip2 encoded. We need to build that dll. NOTE: This feature is not used.

There is a circular dependency between harfbuzz and freetype so you may need with slightly different configure scripts. Lets start with freetype, and build the things that harfbuzz wants and will go back to freetype and some others again.

bzip-1.0.6

You will need some patches in your src/ directory along with this msys2-bzlib.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
  --enable-shared \
  --prefix=${dest}
wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar xf bzip2-1.0.6.tar.gz
wget https://walkabout.mvmanila.com/public/patch/msys2/bzip2-patch.1
wget https://walkabout.mvmanila.com/public/patch/msys2/bzip2-patch.2
cd bzip2-1.0.6
patch -p1 <../bzip2-patch.1
patch -p1 <../bzip2-patch.2

Now you can do a make; make install

msys2-freetype1.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}include"
export LDFLAGS="-L${dest}lib"
export LIBPNG_CFLAGS="-I ${dest}/include/libpng16"
export LIBPNG_LIBS="-L${dest}/lib -lpng16"
export BZIP2_CFLAGS="-I${dest}/include"
export BZIP2_LIBS="-L${dest}/lib"
export PKG_CONFIG_LIBIR="${dest}/lib/pkgconfig:$PKG_CONFIG_PATH"
./configure \
  --enable-shared \
  --with-harfbuzz=no \
  --with-bzip2=no \
  --prefix=${dest}

We build without harfbuzz (because we don't have one yet). Then we'll build some things harfbuzz might like, build it and build freetype again and may rebuild some other things too.

msys2-fontconfig.sh:

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig"
export FREETYPE_CFLAGS="-I${dest}/include/freetype2"
export LIBXML2_CFLAGS="-I${dest}/include/libxml2"
export LIBXML2_LIBS="-L/${dest}/lib -lxml2"
./configure \
  --enable-libxml2 \
  --prefix=${dest}

msys2-harfbuzz.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig:${PKG_CONFIG_PATH}"
export FREETYPE_CFLAGS="-I${dest}/include/freetype2"
./configure \
  --enable-shared \
  --enable-static \
  --prefix=${dest}

freetype - pass two

msys2-freetype2.sh -- there are some differences from msys-freetype1.sh. They might be important.

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}include"
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}lib"
export LIBPNG_CFLAGS="-I ${dest}/include/libpng16"
export LIBPNG_LIBS="-L${dest}/lib -lpng16"
export BZIP2_CFLAGS="-I${dest}/include"
export BZIP2_LIBS="-L${dest}/lib"
export HARFBUZZ_CFLAGS
export HARFBUFF_CFLAGS="-I${dest}/include"
export HARFBUZZ_LIBS="-I${dest}/lib -lharfbuzz"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig"
./configure \
  --enable-shared \
  --with-harfbuzz=yes \
  --with-bzip2=no \
  --prefix=${dest}

Back to Gtk

Now that we are out of the font funny farm we can get to some drawing libraries.

msys2-pixman.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PNG_CFLAGS="-I${dest}/include/libpng16"
export PNG_LIBS="-L${dest}/lib -lpng16"
./configure \
  --prefix=${dest}

This is not the newest cairo. One could try later versions after we get everything put together. You should pay attention to what is found in configuration -perhaps copy/paste the nice report at the end?

msys2-cairo.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig"
#export png_CFLAGS="-I${dest}/include/libpng16"
#export png_LIBS="-L${dest}/lib -lpng16"
./configure \
  --enable-xcb=no \
  --enable-xlib=no \
  --enable-xlib-xrender=no \
  --prefix=${dest}

unlike cairo, this is a newer version. Once Shoes is working, you can experiment with newer versions. Gtk checks for minimal versions so we will be back. Make sure pangocairo is built -- it's a dll in shoesdeps/mingw/bin.

msys2-pango.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export FREETYPE_CFLAGS="-I${dest}/include/freetype2"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig:${PKG_CONFIG_PATH}"
#export PKG_CONFIG_LIBDIR="${dest}/lib/pkgconfig"
#export FONTCONFIG_CFLAGS="-I${dest}/include/fontconfig"
#export CAIRO_CFLAGS="-I${dest}/include/cairo"
#export GLIB_CFLAGS="-I${dest}/include/glib-2.0 -I${dest}/lib/glib-2.0/include"
#export HARFBUZZ_CFLAGS="-I${dest}/include/harfbuzz"
./configure \
  --disable-debug --disable-gtk-doc \
  --disable-installed-tests \
  --prefix=${dest}

!!! WARNING !!! You have to set the $PATH before running make so it finds some programs in your {deps}/mingw/bin. You should set it in your ~/bash_profile because the gtk build is going to use some programs in there too. You could do something like this $ PATH="/c/shoesdeps/mingw/bin:$PATH" make but that's going to get tedious. In my ~/.bash_profile the path now looks like this.

export PATH="/c/shoesdeps/ruby-2.2.6/bin:/c/shoesdeps/mingw/bin:$PATH"

and source ~/.bash_profile Now you can make and make install.

msys2-atk.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig"
./configure \
  --disable-debug \
  --prefix=${dest}

[gdk-pixbuf-2.36.5](https://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/2.36/gdk Note: this is very recent version which fixes some building issues.

msys2-gdk-pixbuf.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_LIBDIR="${dest}/lib/pkgconfig:${PKG_CONFIG_PATH}"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig"
export PNG_CFLAGS="-I${dest}/include/libpng16"
export PNG_LIBS="-L${dest}/lib -lpng16"
./configure \
  --enable-shared \
  --enable-static \
  --with-included-loaders=yes \
  --disable-always-build-tests \
  --disable-man \
  --disable-gtk-doc \
  --disable-debug \
  --prefix=${dest}

We need get themes and icons. In theory, this should sort of match up with with the Gtk version but they are quasi-independent. In theory, we don't need a script, but lets use one, just in case. msys2-hicolor.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
./configure --prefix=${dest}

make does nothing but make install does do something.

The Adwaita theme is built into Gtk but we don't have the icons - hicolor sort of works if you don't look too hard. If you want to use the built in MS-Theme (which you probably do want to use), you'll need the icons to match. There is a performance penalty in Shoes when first used but the appearance is probably worth it. msys2-adwaita.sh

#! /bin/bash
# execute it instead of ./configure
export dest=/c/shoesdeps/mingw
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_PATH=${dest}/lib/pkgconfig
./configure \
  --prefix=${dest}

This is a medium age version of gtk+-3 - newer that an a cross compiled Shoes and there are issues.

msys2-gtk3.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_LIBDIR="${dest}/lib/pkgconfig"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig"
./configure \
  --disable-debug \
  --disable-installed-tests \
  --enable-explicit-deps=no \
  --disable-glibtest \
  --disable-gtk-doc \
  --disable-man \
  --prefix=${dest}

after the ../msys2-gtk.sh to configure you should have a report at the end that looks like:

        GTK+ 3.14.15
        ===========

        GDK backends:         win32
        Print backends:       file lpr
        Dynamic modules:      yes
        Included immodules:   none
        colord support:       no
        Introspection:        no
        Debugging:            no
        Documentation:        no

Now make. Odds are high that after 30 to 45 minutes go by that it will halt with an error 127 a GEN line related to immodules.cache and gtk-query-immodules-3.0.exe. Against everything you've every done when faced with an error -- do another make and it will continue building things with complaints that exe's may not run. That complaint is valid, they won't run here. After another long time it will finish and you do a make install which will copy them to where they will run.

It gets worse. We do want the immodules.cache file that wasn't built. The easiest way is to do it all over again! make clean and make which will die after a long time for the same reason. But now we can fix it. cd modules/input and rm immodules.cache We'll can use the properly installed gtk-query-immodules-3.0.exe to build it.

gtk-query-immodules-3.0.exe *.la  >immodules.cache

Now 'make' and after another painful build, make install

**Wait **- we're not done yet. Make install didn't copy the pkg-config.pc files. It should have. It didn't.

cp gtk+-3.0.pc ../../mingw/lib/pkgconfig/
cp gdk-3.0.pc ../../mingw/lib/pkgconfig/

Now would be a good time to test that gtk3 working. run the 'gtk3-demo.exe` it takes a while to start up, just like Shoes does. Coincidence? No.

Advanced builders might question the need to do a full second rebuild. You could try this (I haven't). When it dies on the first build, cp ../../gtk/gtk-query-immodules-3.0.exe /c/shoesdeps/mingw/bin or wherever you put that. Now it's in your $PATH. do the rm immodules.cache and the gtk-query-immodules-3.0.exe *.la >immodules.cache and make to continue the build and 'make install`. In theory that should work and you won't have to do the second rebuild of gtk.

msys2-svg.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
#export GTK3_CFLAGS="-I${dest}/include"
#export GTK3_LIBS="-L${dest}/lib"
export PKG_CONFIG_PATH="${dest}/lib/pkgconfig"
export PKG_CONFIG_LIBDIR="${dest}/lib/pkgconfig"
./configure \
  --disable-introspection \
  --disable-tools \
  --prefix=${dest}

This is a pretty old version -for example ./configure -h only uses one hypthen. untar, cd and msys2-sql.sh

#! /bin/bash
# execute it instead of ./configure
export dest="/c/shoesdeps/mingw"
./configure --prefix=${dest}

Gems for Shoes

Shoes needs to include some gems. You can install gems into that new Ruby with gem install and they would be included in the Shoes you build. Thats also a way to get newer gems than Shoes knows about and create subtle problems for you and your users. Then again, it's your Shoes.

Or you can download pre-built gems Select cdmsys2-gems-tgz in this case and then the copy it into your C:\shoesdeps\gems\built . Don't worry, there are many ways to stitch things together.

Cecil@bronco7:/C/shoesdeps$ mkdir -p gems/built
Cecil@bronco7:/C/shoesdeps$ cd gems/built
Cecil@bronco7:/C/shoesdeps/gems/built$ cp /C/Users/Cecil/Downloads/msys2-gems.tgz .
Cecil@bronco7:/C/shoesdeps/gems/built$ tar zxf msys2-gems.tgz
Cecil@bronco7:/C/shoesdeps/gems/built$ cd msys2/
Cecil@bronco7:/C/shoesdeps/gems/built/msys2$ ls
activesupport-5.0.0.1  mini_portile2-2.0.0           sqlite3
byebug-8.2.1           multi_json-1.12.1             thread_safe-0.3.5
chipmunk-6.1.3.4       nokogiri-1.6.7.1-x86-mingw32  tzinfo-1.2.2
concurrent-ruby-1.0.2  picky-4.31.3                  url_escape-2009.06.24
ftsearch               rack_fast_escape-2009.06.24   win32-shortcut-0.2.5
hpricot                rb-readline-0.5.3             yajl-ruby-1.3.0
i18n-0.7.0             serialport-1.3.1

Do not be confused by the sqlite3 vs the sqlite3-3.8.5. One is the gem wrapper to the other.

Building Shoes

So, we've got a Ruby to build with, and a ruby to distribute. (two different things, perhaps). We need Shoes source code and a place to put it. Most people should

git clone https://github.com/Shoes3/shoes3.git

and cd into that shoes3 directory. I happen to have my shoes3 source code on a network drive, E:\shoes3

msys2-custom.yaml

Building Shoes is configured with msys2-custom.yaml. Mine happens to be:

Cecil@bronco7:/e/shoes3$ more msys2-custom.yaml
Ruby: C:/shoesdeps/ruby
Deps: C:/shoesdeps/mingw
GtkLoc: C:/shoesdeps/gems
Gemloc: C:/shoesdeps/gems
Extloc: C:/shoesdeps/gems
Exts:
Gems:
  - sqlite3
InclGems:
  - chipmunk-6.1.3.4
  - sqlite3
  - nokogiri-1.6.7.1-x86-mingw32
  - mini_portile2-2.0.0
  - byebug-8.2.1
  - rb-readline-0.5.3
  - win32-shortcut-0.2.5
  # picky needs:
  - activesupport-5.0.0.1
  - concurrent-ruby-1.0.2
  - i18n-0.7.0
  - multi_json-1.12.1
  - picky-4.31.3
  - rack_fast_escape-2009.06.24
  - thread_safe-0.3.5
  - tzinfo-1.2.2
  - url_escape-2009.06.24
  - yajl-ruby-1.3.0
MS-Theme: true
Debug: false
GtkVersion: 3

Now let's build Shoes. Cd to where ever the Shoes source code is stored and see what options you have.

Cecil@bronco7:~$ cd /e/shoes3
Cecil@bronco7:/e/shoes3$ rake -T
rake build                     # Build using your OS setup
rake clean                     # Remove any temporary products
rake clobber                   # Remove any generated file
rake default                   # Same as `rake build'
...
rake package                   # Package Shoes for distribution
...
rake win32:setup:clean         # remove win32 setup
rake win32:setup:msys2         # Windows build with msys2
rake win32:setup:win7          # Windows build with devkit

I only show the options available for Windows and normal building. rake defaults to rake build so we have to tell it what the default is. We do that by telling it to use msys2 or devkit. Since this is a msys2 tutorial we're going to select that one.

Cecil@bronco7:/e/shoes3$ rake.bat win32:setup:msys2
echo TGT_ARCH=msys2 >crosscompile

It is a very good idea to rake.bat clean now. This removes anything leftover from the last build. Now we can build Shoes with a rake.bat which is going to take some time with a lot of messages displayed. There are progress messages - doing this and warning messages (most of you can ignore warnings). error messages stop things and and you'll have to figure out what's missing or wrong (in that custom.yaml?)

Success looks like

Copying prebuilt gem C:/shoesdeps/gems/built/msys2/yajl-ruby-1.3.0
Lib copy = lib
copy_files_to_dist dir=E:/shoes3
copy_deps_to_dist dir=E:/shoes3
Cecil@bronco7:/e/shoes3$

Can we run the new Shoes we built? It was placed in a msys2 sub-directory.

Cecil@bronco7:/e/shoes3$ ./msys2/cshoes.exe

Congratulations if you get the Shoes splash screen. Way to go.

Clone this wiki locally