Monday, May 06, 2013

Building GTK+ 3 Library

I have spent my days building GTK+ 3 and components for my project inside my Thinkpad E125 running on Ubuntu 10.04 LTS (Lucid Lynx).

Below are GTK+ 3 components that need to be downloaded from their respective project site:
Installation directory is under /opt/gtk, pkg-config ($PKG_CONFIG_PATH), dynamic library ($LD_LIBRARY_PATH) and system path ($PATH) environment variable should be determined (depends on package) in order to configure and compile each package. Notice that I passed extraction process for each package and cover only build and installation.

Also it is important to have a correct version for package dependency, for example GTK+ 3.6.4 requires at least version 2.34.x of Glib, as well as other package. gtk-doc is optional (enabled with --enable-gtk-doc configure argument) to generate GTK+ HTML style documentation which very important to me.

So here are the building steps:
  • gtk-doc-1.18
    $ ./configure && make && sudo make install
  • glib-2.34.3
    $ ./configure --prefix=/opt/gtk --enable-gtk-doc
    $ make && sudo make install
  • atk-2.6.0
    $ PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig LD_LIBRARY_PATH=/opt/gtk/lib ./configure --prefix=/opt/gtk --enable-gtk-doc
    $ make && sudo make install
  • at-spi2-core-2.6.3
    $ PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig LD_LIBRARY_PATH=/opt/gtk/lib ./configure --prefix=/opt/gtk
    $ make && sudo make install
  • at-spi2-atk-2.6.2
    $ PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig LD_LIBRARY_PATH=/opt/gtk/lib ./configure --prefix=/opt/gtk
    $ PATH=/opt/gtk/bin:$PATH make
    $ sudo PATH=$PATH:/opt/gtk/bin make install
  • pixman-0.28.2
    $ ./configure --prefix=/opt/gtk
    $ make && sudo make install
  • cairo-1.2.14
    $ PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig ./configure --prefix=/opt/gtk --enable-gtk-doc
    $ make && sudo make install
  • gdk-pixbuf-2.29.0
    $ PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig LD_LIBRARY_PATH=/opt/gtk/lib ./configure --prefix=/opt/gtk --enable-gtk-doc --without-libtiff
    $ make && sudo make install
  • freetype-2.4.11
    $ ./configure --prefix=/opt/gtk
    $ make && sudo make install
  • fontconfig-2.10.91
    $ ./configure --prefix=/opt/gtk
    $ make && sudo make install
  • harfbuzz-0.9.16
    $ ./configure --prefix=/opt/gtk
    $ make && sudo make install
  • pango-1.32.5
    $ PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig ./configure --prefix=/opt/gtk --enable-gtk-doc
    $ make && sudo make install
  • gtk+-3.6.4
    $ PATH=/opt/gtk/bin:$PATH PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig LD_LIBRARY_PATH=/opt/gtk/lib ./configure --prefix=/opt/gtk --enable-gtk-doc --enable-packagekit=no
    $ PATH=/opt/gtk/bin:$PATH make
    $ PATH=/opt/gtk/bin:$PATH sudo make install
To test if the build was successful, the easy way is to run gtk3-demo program inside /opt/gtk/bin, previously have provided dynamic module path either in ld.so.conf or by set LD_LIBRARY_PATH environment variable at the runtime, for example:

$ LD_LIBRARY_PATH=/opt/gtk/lib /opt/gtk/bin/gtk3-demo

To compile and link against GTK+ 3 (or any component), use pkg-config environment variable PKG_CONFIG_PATH to set GTK+ 3 pkg-config file location for both --cflags and --libs argument.