MinGW/MSYS development environment
Part 3: Building GTK+
. Index .. Base system .. Local packages .. GTK+ .. Qt .. Tools .. Projects .. Home .

This section describes how to compile the GTK+ library and necessary dependencies.

Content

Building libiconv

libiconv is a text encoding library.

cd ${LOCALSOURCEDIR} && \
wget -c http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz && \
cd ${LOCALBUILDDIR} && \
tar xzf ${LOCALSOURCEDIR}/libiconv-1.15.tar.gz && \
cd libiconv-1.15 && \
./configure --prefix=${LOCALDESTDIR} --docdir=${LOCALDESTDIR}/share/doc/libiconv-1.15 && \
make && \
make install
Building gettext

gettext is a tool for localizing and translating programs.

Build and install the gettext runtime by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.tar.gz && \
cd ${LOCALBUILDDIR} && \
tar xzf ${LOCALSOURCEDIR}/gettext-0.19.8.tar.gz && \
mv gettext-0.19.8 gettext-0.19.8-runtime && \
cd gettext-0.19.8-runtime && \
cat gettext-tools/woe32dll/gettextlib-exports.c | grep -v rpl_opt > gettext-tools/woe32dll/gettextlib-exports.c.new && \
mv gettext-tools/woe32dll/gettextlib-exports.c.new gettext-tools/woe32dll/gettextlib-exports.c && \
CFLAGS="-mms-bitfields -mthreads -O2" ./configure --prefix=${LOCALDESTDIR} --enable-threads=win32 --enable-relocatable && \
cd gettext-runtime && \
make && \
make install

Build and install the gettext tools by executing the following commands:

cd ${LOCALBUILDDIR} && \
tar xzf ${LOCALSOURCEDIR}/gettext-0.19.8.tar.gz && \
mv gettext-0.19.8 gettext-0.19.8-static && \
cd gettext-0.19.8-static && \
CFLAGS="-mms-bitfields -mthreads -O2" ./configure --prefix=${LOCALDESTDIR} --enable-threads=win32 --enable-relocatable --disable-shared && \
make && \
install gettext-tools/src/msgfmt.exe ${LOCALDESTDIR}/bin && \
install gettext-tools/src/msgmerge.exe ${LOCALDESTDIR}/bin && \
install gettext-tools/src/xgettext.exe ${LOCALDESTDIR}/bin

References:

Building ICU

ICU are the International Components for Unicode.

The latest version icu4c-59_1 fails to build in the current environment. It looks there is a bug or incompatibility on mingw-w64. We build the previous version instead.

Build and install ICU by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget --no-check-certificate -c http://download.icu-project.org/files/icu4c/58.2/icu4c-58_2-src.tgz && \
cd ${LOCALBUILDDIR} && \
tar zxf ${LOCALSOURCEDIR}/icu4c-58_2-src.tgz && \
mv icu icu4c-58_2 && \
cd icu4c-58_2 && \
cd source && \
./configure --prefix=${LOCALDESTDIR}  && \
make && \
make install

References:

Building libffi

libffi is a a portable foreign function interface library.

The 64-bit build requires ./configure --build=x86_64-w64-mingw32 --prefix=${LOCALDESTDIR}

Build and install libffi by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c ftp://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz && \
cd ${LOCALBUILDDIR} && \
tar zxf ${LOCALSOURCEDIR}/libffi-3.2.1.tar.gz && \
cd libffi-3.2.1 && \
sed -e '/^includesdir/ s/$(libdir).*$/$(includedir)/' \
    -i include/Makefile.in &&
sed -e '/^includedir/ s/=.*$/=@includedir@/' \
    -e 's/^Cflags: -I${includedir}/Cflags:/' \
    -i libffi.pc.in        &&
./configure --prefix=${LOCALDESTDIR}  && \
make && \
make install

References:

Building glib

glib is a low-level core library that forms the basis of GTK+.

The 64-bit build requires ./configure --build=x86_64-w64-mingw32 --prefix=${LOCALDESTDIR} --with-pcre=internal --enable-debug=no --disable-gtk-doc

Build and install glib by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c http://ftp.acc.umu.se/pub/gnome/sources/glib/2.52/glib-2.52.2.tar.xz && \
cd ${LOCALBUILDDIR} && \
tar xJf ${LOCALSOURCEDIR}/glib-2.52.2.tar.xz && \
cd glib-2.52.2 && \
./configure --prefix=${LOCALDESTDIR} --with-pcre=internal --enable-debug=no --disable-gtk-doc && \
make && \
make install
Building pkg-config

pkg-config is a helper tool used when compiling applications and libraries.

This build will replace the static binary we installed earlier.

Build and install pkg-config by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c --no-check-certificate http://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz && \
cd ${LOCALBUILDDIR} && \
tar xzf ${LOCALSOURCEDIR}/pkg-config-0.29.2.tar.gz && \
cd pkg-config-0.29.2 && \
./configure --prefix=${LOCALDESTDIR} && \
make && \
make install
Building freetype (pass one)

Freetype is a library for rendering TrueType fonts.

Build and install freetype by executing the following commands:

cd ${LOCALSOURCEDIR}  && \
wget -c http://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.bz2 && \
wget -c http://ingar.satgnu.net/devenv/mingw32/files/patches/freetype-2.8-config.patch && \
cd ${LOCALBUILDDIR} && \
tar xjf ${LOCALSOURCEDIR}/freetype-2.8.tar.bz2 && \
mv freetype-2.8 freetype-2.8-without-harfbuzz && \
cd freetype-2.8-without-harfbuzz && \
patch -Np0 -i ${LOCALSOURCEDIR}/freetype-2.8-config.patch && \
./configure --prefix=${LOCALDESTDIR} && \
make && \
make install

Command explanation:

patch -Np1 -i ${LOCALSOURCEDIR}/freetype-2.8-config.patch
Enables the FT_CONFIG_OPTION_SUBPIXEL_RENDERING, FT_CONFIG_OPTION_SYSTEM_ZLIB and FT_CONFIG_OPTION_USE_PNG options.
Building harfbuzz

Harfbuzz is een OpenType text shaping engine.

Build and install libffi by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c --no-check-certificate http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-1.4.6.tar.bz2 && \
cd ${LOCALBUILDDIR} && \
( tar jxf ${LOCALSOURCEDIR}/harfbuzz-1.4.6.tar.bz2 || exit 0 ) && \
cd harfbuzz-1.4.6 && \
./configure --prefix=${LOCALDESTDIR} --with-gobject && \
make && \
make install

Command explanation:

( tar jxf ${LOCALSOURCEDIR}/harfbuzz-1.4.6.tar.bz2 || exit 0 ) && \
The tar command returns a non-zero exit code, this interrupts the command sequence.

Building freetype (pass two)

At this point you need to build freetype a second time, to work around a circular dependency between harfbuzz and freetype.

cd ${LOCALSOURCEDIR}  && \
wget -c http://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.bz2 && \
wget -c http://ingar.satgnu.net/devenv/mingw32/files/patches/freetype-2.8-config.patch && \
wget -c http://ingar.satgnu.net/devenv/mingw32/files/patches/freetype-2.8-config-harfbuzz.patch && \
cd ${LOCALBUILDDIR} && \
tar xjf ${LOCALSOURCEDIR}/freetype-2.8.tar.bz2 && \
cd freetype-2.8 && \
patch -Np0 -i ${LOCALSOURCEDIR}/freetype-2.8-config.patch && \
patch -Np0 -i ${LOCALSOURCEDIR}/freetype-2.8-config-harfbuzz.patch && \
./configure --prefix=${LOCALDESTDIR} && \
make && \
make install

If you need the SDL2_ttf library, you can build it now.

Building expat

expat is an XML parsing library.

Build and install expat by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget --no-check-certificate -c https://downloads.sourceforge.net/project/expat/expat/2.2.0/expat-2.2.0.tar.bz2 && \
cd ${LOCALBUILDDIR} && \
tar xjf ${LOCALSOURCEDIR}/expat-2.2.0.tar.bz2 && \
cd expat-2.2.0 && \
./configure --prefix=${LOCALDESTDIR} && \
make && \
make install

Building libxml2

libxml2 is an XML parsing library.

Build and install libxml2 by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz && \
cd ${LOCALBUILDDIR} && \
tar xzf ${LOCALSOURCEDIR}/libxml2-2.9.4.tar.gz && \
cd libxml2-2.9.4 && \
./configure --prefix=${LOCALDESTDIR} --with-zlib=${LOCALDESTDIR} --without-python --without-debug && \
make && \
make install

Configuration options:

--without-python
libxml2 fails to build if it finds python in your PATH. Add this configure option to disable python detection.

Building libxslt

libxslt extends libxml2 with support for XSLT files.

Build and install libxslt by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c http://xmlsoft.org/sources/libxslt-1.1.29.tar.gz && \
cd ${LOCALBUILDDIR} && \
tar xzf ${LOCALSOURCEDIR}/libxslt-1.1.29.tar.gz && \
cd libxslt-1.1.29 && \
autoreconf -fi && \
./configure --prefix=${LOCALDESTDIR} --without-python --without-debug && \
make && \
make install

Command explanation:

autoreconf -fi
Update the ./configure script and related autoconf files. Without this, only a static library and no DLL will be built.
Buildling gperf

Gperf generates a perfect hash function from a key set.

Build and install gperf by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c --no-check-certificate http://ftp.gnu.org/pub/gnu/gperf/gperf-3.1.tar.gz && \
cd ${LOCALBUILDDIR} && \
tar xzf ${LOCALSOURCEDIR}/gperf-3.1.tar.gz && \
cd gperf-3.1 && \
./configure --prefix=${LOCALDESTDIR} --docdir=${LOCALDESTDIR}/share/doc/gperf-3.1 && \
make && \
make install
Building fontconfig

fontconfig is a library for font customization and configuration.

Build and install fontconfig by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c --no-check-certificate http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.3.tar.gz && \
wget -c http://ingar.satgnu.net/devenv/mingw32/files/patches/fontconfig-2.12.3-size_t.patch && \
cd ${LOCALBUILDDIR} && \
tar xzf ${LOCALSOURCEDIR}/fontconfig-2.12.3.tar.gz && \
cd fontconfig-2.12.3 && \
patch -Np1 -i ${LOCALSOURCEDIR}/fontconfig-2.12.3-size_t.patch && \
./configure --prefix=${LOCALDESTDIR} --enable-libxml2 --disable-docs && \
make && \
make install
Building pixman

pixman is a low-level pixel manipulation library.

Build and install pixman by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget --no-check-certificate -c http://cairographics.org/releases/pixman-0.34.0.tar.gz && \
cd ${LOCALBUILDDIR} && \
tar xzf ${LOCALSOURCEDIR}/pixman-0.34.0.tar.gz && \
cd pixman-0.34.0 && \
./configure --prefix=${LOCALDESTDIR} && \
make && \
make install

Building cairo

cairo is a 2d graphics library.

Build and install cairo by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget --no-check-certificate -c http://cairographics.org/releases/cairo-1.14.8.tar.xz && \
cd ${LOCALBUILDDIR} && \
tar xJf ${LOCALSOURCEDIR}/cairo-1.14.8.tar.xz && \
cd cairo-1.14.8 && \
./configure --prefix=${LOCALDESTDIR} && \
make && \
make install
Building pango

pango is a text rendering library.

Build and install pango by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c http://ftp.gnome.org/pub/gnome/sources/pango/1.40/pango-1.40.6.tar.xz && \
cd ${LOCALBUILDDIR} && \
tar xJf ${LOCALSOURCEDIR}/pango-1.40.6.tar.xz && \
cd pango-1.40.6 && \
./configure --prefix=${LOCALDESTDIR} --with-included-modules=yes --disable-debug --disable-gtk-doc && \
make && \
make install

Configuration options:

--with-included-modules=yes
This options causes pango modules to be staticly linked into the main library.

Building atk

atk is the gnome accessibility toolkit.

Build and install atk by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c http://ftp.gnome.org/pub/gnome/sources/atk/2.24/atk-2.24.0.tar.xz && \
cd ${LOCALBUILDDIR} && \
tar xJf ${LOCALSOURCEDIR}/atk-2.24.0.tar.xz && \
cd atk-2.24.0 && \
./configure --prefix=${LOCALDESTDIR} && \
make && \
make install

Building gdk-pixbuf

GdkPixBuf provides pixel buffer and rendering functions.

Build and install GdkPixBuf by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/2.36/gdk-pixbuf-2.36.6.tar.xz && \
cd ${LOCALBUILDDIR} && \
tar xJf ${LOCALSOURCEDIR}/gdk-pixbuf-2.36.6.tar.xz && \
cd gdk-pixbuf-2.36.6 && \
./configure --prefix=${LOCALDESTDIR} --with-included-loaders=yes \
--without-libjasper --disable-debug && \
make && \
make install

Configuration options::

--with-included-loaders=yes
This option causes the gdk image loaders to be staticly linked into the gdk-pixbuf library
--without-libjasper
disable JPEG2000 support

Building gtk2

gtk2 is an application framework library.

The 32-bit build will fail around gtk-update-icon-cache unless you run the msys shell as administrator.

Build and install gtk2 by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c http://ftp.gnome.org/pub/gnome/sources/gtk+/2.24/gtk+-2.24.31.tar.xz && \
cd ${LOCALBUILDDIR} && \
tar xJf ${LOCALSOURCEDIR}/gtk+-2.24.31.tar.xz && \
cd gtk+-2.24.31 && \
./configure --prefix=${LOCALDESTDIR} --with-gdktarget=win32 --with-included-immodules=ime --disable-debug --disable-gtk-doc && \
rm gtk/gtk.def && \
make && \
make install

Configuration options:

--with-included-immodules=ime
This options causes the ime input module to be staticly linked into the main library.
--disable-debug
Do not add debugging information.
--disable-gtk-doc
Do not build the documentation, we do not have gtk-doc installed anyway.

Command explanation:

rm gtk/gtk.def
The 64-bit build fails if this file is not removed.

At this point, you should test your gtk installation. The pixbuf-demo demonstrates image capabilities.

cd demos
./pixbuf-demo

You should see a window with rotating icons.


The gtk-demo demonstrates gtk2 widgets:

cd gtk-demo
gtk-demo

References:

Building gtkglext

gtkglext is an opengl extension for gtk2

gtkglext does not build without patching, the patch provided is from the arch linux gtkglext package.

Build and install gtkglext by executing the following commands:

cd ${LOCALSOURCEDIR} && \
wget -c --no-check-certificate https://downloads.sourceforge.net/gtkglext/gtkglext-1.2.0.tar.gz && \
wget -c http://ingar.satgnu.net/devenv/mingw32/files/patches/gtkglext-1.2.0-gtk-2.20.patch && \
cd ${LOCALBUILDDIR} && \
tar xzf ${LOCALSOURCEDIR}/gtkglext-1.2.0.tar.gz && \
cd gtkglext-1.2.0 && \
patch -Np1 -i ${LOCALSOURCEDIR}/gtkglext-1.2.0-gtk-2.20.patch && \
cat configure | sed 's/pangox/pangowin32/' > configure.new && \
mv configure.new configure && \
./configure --prefix=${LOCALDESTDIR} --with-gdktarget=win32 --enable-debug=no && \
make && \
make install && \
cd examples && \
make wglinfo.exe && \
install wglinfo.exe ${LOCALDESTDIR}/bin

Command explanation:

cat configure | sed 's/pangox/pangowin32/' > configure.new && mv configure.new configure
These commands correct the configure script so it links binaries with the pango win32 library instead of the pango X11 libraries.

Build and install the wglinfo program:

cd examples
make wglinfo.exe
install wglinfo.exe ${LOCALDESTDIR}/bin