Linux HOWTOs

About | Home | Search


HOWTO: glib
Description: Low-level core library used by GTK+, Gnome, and many others
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# GLib
# ====
# GLib is used by these and lots more:
# GTK+
# Gnome
# Wireshark
# Enchant
# Gaim
# mc
# nano
# nmap,
# X-CD-Roast
# Pan
# The Gimp
# ...

# Slackware 8.1 onward includes a 'glib' package at version 1.2.10
#
# Slackware's 'glib2' package includes:
# Slackware 12.1: 2.14.6
# Slackware 12.2: 2.16.6
# Slackware 13.0: 2.18.4
# Slackware 13.1: 2.22.5
# Slackware 13.37: 2.28.6

# There are several major (2.16.x, 2.18.x, etc.) versions of GLib below.
# The latest 1.2.x version, which is very old but is still used by quite a
# few apps, and the latest 2.x.x versions.  See notes below for more info
# about each one.

# Prerequisites (for all versions):
# pkg-config
# Perl
# indent
# iconv
# grep
# gettext

# To ensure that old files aren't left when upgrading from one source
# installed version to another, skip down to the bottom for uninstall
# instructions.

# If you have a GLib (1.x or 2.x) that was installed under /usr/local, cd
# into it's source and run 'make uninstall' before continuing here.  To
# clean out the empty directories it'll leave behind, look over the
# uninstall instructions at the bottom (but use /usr/local/* instead of
# /usr/*).


# GLib 1.2.10 (GTK+ 1.2.x)
# ===========
cd
test -f installed/glib-1.2.10.tar.gz && mv installed/glib-1.2.10.tar.gz .
test ! -f glib-1.2.10.tar.gz &&
 wget ftp://ftp.gtk.org/pub/gtk/v1.2/glib-1.2.10.tar.gz
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "glib-1.*" -exec rm -r {} \;
tar xzvf ~/glib-1.2.10.tar.gz
cd glib-1.2.10
test $UID = 0 && chown -R root:root .
./configure --prefix=/usr --sysconfdir=/etc
make

# Become root to install it
su

test -x /sbin/removepkg && /sbin/removepkg glib
rm -f /usr/include/glib.h /usr/include/gmodule.h
rm -f /usr/lib/libglib-1.*.so*
make install
ldconfig

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/glib-1.*.tar.*
mv glib-1.2.10.tar.gz installed/

# Skip down to the bottom for uninstall notes and info about cleaning
# up the elflibs package file


# GLib 2.12.13  (GTK+ 2.10.x)
# ===========
# Prerequisites (beyond those listed above):
# gtk-doc > 1.0 (Slackware includes this in it's sgml-tools/linuxdoc-tools
#  packages, it will be used if --enable-gtk-doc is passed to configure)

# If you have trouble downloading it with the URL below, you can also
# get it here:
# http://download.gnome.org/sources/glib/2.12/

cd
test -f installed/glib-2.12.13.tar.bz2 && mv installed/glib-2.12.13.tar.bz2 .
test ! -f glib-2.12.13.tar.bz2 &&
 wget ftp://ftp.gtk.org/pub/glib/2.14/glib-2.12.13.tar.bz2

# Verify tarball w/ md5sum:
echo "d76124236e4e216e8c0861341e967a76  glib-2.12.13.tar.bz2" | md5sum -c

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "glib-2.*" -exec rm -r {} \;
tar xjvf ~/glib-2.12.13.tar.bz2
cd glib-2.12.13
test $UID = 0 && chown -R root:root .

# If you want to build GLib with optimizations, pass CFLAGS to configure
# below.  I use CFLAGS="-O2 -march=pentium4" for this box which has a
# Pentium IV (4) processor.
# This is what I run:
# CFLAGS="-O2 -march=pentium4" \
# ./configure --prefix=/usr --sysconfdir=/etc --with-libiconv=gnu
# Obviously, make sure you specify your type of processor there (see 'man
# gcc' for others).  If you use a gcc older than 3.2.x you'll need to use
# 'i686' instead.

# If you have the GNU libiconv library (vs. glibc's iconv) installed, add
# --with-libiconv=gnu to the configure line below

# If you want to let make run multiple jobs simultaneously (if you have
# multiple processors), add -j3 when you run make below to run 3 jobs at
# once

./configure --prefix=/usr --sysconfdir=/etc
make

# Become root to install it
su

test -x /sbin/removepkg && /sbin/removepkg glib2
rm -f /usr/include/glib.h /usr/include/gmodule.h
rm -f /usr/lib/libglib-2.*.so*
make install
ldconfig
chown -R $USER .

# I'm in the US and only read/write English (well), so I don't need these
find /usr/share/locale -type f -name "glib20.mo" -exec rm {} \;

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/glib-2.*.tar.*
mv glib-2.12.13.tar.bz2 installed/


# GLib 2.14.5  (GTK+ 2.12.x)
# ===========
# Prerequisites (beyond those listed above):
# gtk-doc > 1.0 (Slackware includes this in it's sgml-tools/linuxdoc-tools
#  packages, it will be used if --enable-gtk-doc is passed to configure)

# If you have trouble downloading it with the URL below, you can also
# get it here:
# http://download.gnome.org/sources/glib/2.14/

cd
test -f installed/glib-2.14.5.tar.bz2 && mv installed/glib-2.14.5.tar.bz2 .
test ! -f glib-2.14.5.tar.bz2 &&
 wget ftp://ftp.gtk.org/pub/glib/2.14/glib-2.14.5.tar.bz2

# Verify tarball w/ md5sum:
echo "c7eedaacd39d3606c307da5ea7fc7018  glib-2.14.5.tar.bz2" | md5sum -c

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "glib-2.*" -exec rm -r {} \;
tar xjvf ~/glib-2.14.5.tar.bz2
cd glib-2.14.5
test $UID = 0 && chown -R root:root .

# If you want to build GLib with optimizations, pass CFLAGS to configure
# below.  I use CFLAGS="-O2 -march=pentium4" for this box which has a
# Pentium IV (4) processor.
# This is what I run:
# CFLAGS="-O2 -march=pentium4" \
# ./configure --prefix=/usr --sysconfdir=/etc --with-libiconv=gnu
# Obviously, make sure you specify your type of processor there (see 'man
# gcc' for others).  If you use a gcc older than 3.2.x you'll need to use
# 'i686' instead.

# If you have the GNU libiconv library (vs. glibc's iconv) installed, add
# --with-libiconv=gnu to the configure line below

# If you want to let make run multiple jobs simultaneously (if you have
# multiple processors), add -j3 when you run make below to run 3 jobs at
# once

./configure --prefix=/usr --sysconfdir=/etc
make

# Become root to install it
su

test -x /sbin/removepkg && /sbin/removepkg glib2
rm -f /usr/include/glib.h /usr/include/gmodule.h
rm -f /usr/lib/libglib-2.*.so*
make install
ldconfig
chown -R $USER .

# I'm in the US and only read/write English (well), so I don't need these
find /usr/share/locale -type f -name "glib20.mo" -exec rm {} \;

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/glib-2.*.tar.*
mv glib-2.14.5.tar.bz2 installed/


# GLib 2.16.6
# ===========
# Prerequisites (beyond those listed above):
# gtk-doc > 1.0 (Slackware includes this in it's sgml-tools/linuxdoc-tools
#  packages, it will be used if --enable-gtk-doc is passed to configure)

# If you have trouble downloading it with the URL below, you can also
# get it here:
# http://download.gnome.org/sources/glib/2.16/

cd
test -f installed/glib-2.16.6.tar.bz2 && mv installed/glib-2.16.6.tar.bz2 .
test ! -f glib-2.16.6.tar.bz2 &&
 wget ftp://ftp.gtk.org/pub/glib/2.16/glib-2.16.6.tar.bz2

# Verify tarball w/ md5sum:
echo "664e59093c31896a3a46b7cd93fdd3dd  glib-2.16.6.tar.bz2" | md5sum -c

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "glib-2.*" -exec rm -r {} \;
tar xjvf ~/glib-2.16.6.tar.bz2
cd glib-2.16.6
test $UID = 0 && chown -R root:root .

# If you want to build GLib with optimizations, pass CFLAGS to configure
# below.  I use CFLAGS="-O2 -march=pentium4" for this box which has a
# Pentium IV (4) processor.
# This is what I run:
# CFLAGS="-O2 -march=pentium4" \
# ./configure --prefix=/usr --sysconfdir=/etc --with-libiconv=gnu
# Obviously, make sure you specify your type of processor there (see 'man
# gcc' for others).  If you use a gcc older than 3.2.x you'll need to use
# 'i686' instead.

# If you have the GNU libiconv library (vs. glibc's iconv) installed, add
# --with-libiconv=gnu to the configure line below

# If you want to let make run multiple jobs simultaneously (if you have
# multiple processors), add -j3 when you run make below to run 3 jobs at
# once

./configure --prefix=/usr --sysconfdir=/etc
make

# Become root to install it
su

test -x /sbin/removepkg && /sbin/removepkg glib2
rm -f /usr/include/glib.h /usr/include/gmodule.h
rm -f /usr/lib/libglib-2.*.so*
make install
ldconfig
chown -R $USER .

# I'm in the US and only read/write English (well), so I don't need these
find /usr/share/locale -type f -name "glib20.mo" -exec rm {} \;

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/glib-2.*.tar.*
mv glib-2.16.6.tar.bz2 installed/


# GLib 2.18.4 (GTK+ 2.14.x)
# ===========
# Prerequisites (beyond those listed above):
# gtk-doc > 1.0 (Slackware includes this in it's sgml-tools/linuxdoc-tools
#  packages, it will be used if --enable-gtk-doc is passed to configure)
# Python (for Python bindings)
# SELinux support (optional)
# inotify in your kernel (optional)
#  (you may need to symlink /usr/include/linux/inotify.h to
#  /usr/include/sys/inotify.h for this - I haven't tried)
# fam (optional)

# If you have trouble downloading it with the URL below, you can also
# get it here:
# http://download.gnome.org/sources/glib/2.18/

cd
test -f installed/glib-2.18.4.tar.bz2 && mv installed/glib-2.18.4.tar.bz2 .
test ! -f glib-2.18.4.tar.bz2 &&
 wget ftp://ftp.gtk.org/pub/glib/2.18/glib-2.18.4.tar.bz2

# Verify tarball w/ md5sum:
echo "ec25ed261534d870141000ab73f1a2bf  glib-2.18.4.tar.bz2" | md5sum -c

# Verify tarball w/ sha256sum:
echo "6aeb2c845e9fdc388943acdaba2f6357e3007c5ffaa8d666904679cfb40de100  \
glib-2.18.4.tar.bz2" | sha256sum -c

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "glib-2.*" -exec rm -r {} \;
tar xjvf ~/glib-2.18.4.tar.bz2
cd glib-2.18.4
test $UID = 0 && chown -R root:root .

# If you want to build GLib with optimizations, pass CFLAGS to configure
# below.  I use CFLAGS="-O2 -march=pentium4" for this box which has a
# Pentium IV (4) processor.
# This is what I run:
# CFLAGS="-O2 -march=pentium4" \
# ./configure --prefix=/usr --sysconfdir=/etc --with-libiconv=gnu
# Obviously, make sure you specify your type of processor there (see 'man
# gcc' for others).  If you use a gcc older than 3.2.x you'll need to use
# 'i686' instead.

# If you have the GNU libiconv library (vs. glibc's iconv) installed, add
# --with-libiconv=gnu to the configure line below

# If you want to let make run multiple jobs simultaneously (if you have
# multiple processors), add -j3 when you run make below to run 3 jobs at
# once

./configure --prefix=/usr --sysconfdir=/etc
make

# Become root to install it
su

# Remove old files that may cause trouble, install the new version
test -x /sbin/removepkg && /sbin/removepkg glib2
rm -f /usr/include/glib.h /usr/include/gmodule.h
rm -f /usr/lib/libglib-2.*.so*
make install
ldconfig

# Make sure your non-root user can remove the source later
chown -R $USER .
chmod -R u+w .

# I'm in the US and only read/write English (well), so I don't need these
find /usr/share/locale -type f -name "glib20.mo" -exec rm {} \;

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/glib-2.*.tar.*
mv glib-2.18.4.tar.bz2 installed/


# GLib 2.28.8 (GTK+ 3.0.x)
# ===========
# Prerequisites (beyond those listed above):
# gtk-doc > 1.0 (Slackware includes this in it's sgml-tools/linuxdoc-tools
#  packages, it will be used if --enable-gtk-doc is passed to configure)
# Python (for Python bindings)
# SELinux support (optional)
# inotify in your kernel (optional)
#  (you may need to symlink /usr/include/linux/inotify.h to
#  /usr/include/sys/inotify.h for this - I haven't tried)
# fam (optional)

# If you have trouble downloading it with the URL below, you can also
# get it here:
# http://download.gnome.org/sources/glib/2.28/
# http://ftp.gnome.org/pub/gnome/sources/glib/2.28/

cd
test -f installed/glib-2.28.8.tar.bz2 && mv installed/glib-2.28.8.tar.bz2 .
test ! -f glib-2.28.8.tar.bz2 &&
 wget ftp://ftp.gtk.org/pub/glib/2.28/glib-2.28.8.tar.bz2

# Verify tarball w/ md5sum:
# (this came from my sha1sum-verified tarball)
echo "789e7520f71c6a4bf08bc683ec764d24  glib-2.28.8.tar.bz2" | md5sum -c

# Verify tarball w/ sha256sum:
echo "222f3055d6c413417b50901008c654865e5a311c73f0ae918b0a9978d1f9466f  \
glib-2.28.8.tar.bz2" | sha256sum -c

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "glib-2.*" -exec rm -r {} \;
tar xjvf ~/glib-2.28.8.tar.bz2
cd glib-2.28.8
test $UID = 0 && chown -R root:root .

# If you want to build GLib with optimizations, pass CFLAGS to configure
# below.  I use CFLAGS="-O2 -march=pentium4" for this box which has a
# Pentium IV (4) processor.
# This is what I run:
# CFLAGS="-O2 -march=pentium4" \
# ./configure --prefix=/usr --sysconfdir=/etc --with-libiconv=gnu
# Obviously, make sure you specify your type of processor there (see 'man
# gcc' for others).  If you use a gcc older than 3.2.x you'll need to use
# 'i686' instead.

# If you have the GNU libiconv library (vs. glibc's iconv) installed, add
# --with-libiconv=gnu to the configure line below

# If you want to let make run multiple jobs simultaneously (if you have
# multiple processors), add -j3 when you run make below to run 3 jobs at
# once

./configure --prefix=/usr --sysconfdir=/etc
make

# Become root to install it
su

# Remove old files that may cause trouble, including the Slackware package
test -x /sbin/removepkg && /sbin/removepkg glib2
rm -f /usr/include/glib.h /usr/include/gmodule.h
rm -f /usr/lib/libglib-2.*.so*

# Install the new version
make install
ldconfig

# Make sure your non-root user can remove the source later
chown -R $USER .
chmod -R u+w .

# I'm in the US and only read/write English (well), so I don't need these
find /usr/share/locale -type f -name "glib20.mo" -exec rm {} \;

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/glib-2.*.tar.*
mv glib-2.28.8.tar.bz2 installed/


# Now that you've replaced the original Slackware-installed library files,
# you may want to remove lines from the elflibs package file that refer to
# those files:
su
FNAME=`find /var/adm/packages/*elflibs* -type f 2> /dev/null | head -1`
test -n "$FNAME" &&
(
 cat $FNAME | \
  egrep -v "^usr/lib/libglib-2.0.so." | \
  egrep -v "^usr/lib/libgmodule-2.0.so." | \
  egrep -v "^usr/lib/libgobject-2.0.so." | \
  egrep -v "^usr/lib/libgthread-2.0.so." > ${FNAME}.new
 test -s ${FNAME}.new &&
 (
  mkdir -p -m 0700 ~/backup/packages
  mv -f $FNAME ${FNAME}.`date +%Y%m%d`
  mv ${FNAME}.`date +%Y%m%d` ~/backup/packages/
  mv -f ${FNAME}.new $FNAME
 )
)
unset FNAME
exit


# If you ever want to uninstall Glib 1.x, this should do it:
cd
su
test -d src/glib-1.* && ( cd src/glib-1.* ; make uninstall )
( cd /usr/bin ; rm -f glib-config )
find /usr/doc -maxdepth -type d -name "glib-1.*" -exec rm -r {} \;
test -d /usr/include/glib-1.2 && rm -r /usr/include/glib-1.2
( cd /usr/info ; rm -f glib.info glib.info.gz )
( cd /usr/lib ; rm -f libglib.* libglib-1.* libgmodule.* libgmodule-1.* \
 libgthread.* libgthread-1.* )
test -d /usr/lib/glib && rm -r /usr/lib/glib
( cd /usr/lib/pkgconfig ; rm -f glib.pc gmodule.pc gthread.pc )
( cd /usr/man/man1 ; rm -f glib-config.1 glib-config.1.gz )
rm -f /usr/share/aclocal/glib.m4
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "glib-1.*" -exec rm -r {} \;
rm -f ~/installed/glib-1.*.tar.*


# If you ever want to uninstall Glib 2.x, this should do it:
cd
su
test -d src/glib-2.* && ( cd src/glib-2.* ; make uninstall )
( cd /usr/bin ; rm -f glib-genmarshal glib-gettextize glib-mkenums \
 gobject-query )
find /usr/doc -maxdepth -type d -name "glib-2.*" -exec rm -r {} \;
rm -f /usr/include/glib.h /usr/include/gmodule.h
test -d /usr/include/glib-2.0 && rm -r /usr/include/glib-2.0
( cd /usr/lib ; rm -f libglib-2.* libgmodule-2.* libgobject-2.* \
 libgthread-2.* )
( cd /usr/lib/pkgconfig ; rm -f glib-2.0.pc gmodule-2.0.pc \
 gmodule-no-export-2.0.pc gobject-2.0.pc gthread-2.0.pc )
test -d /usr/lib/glib-2.0 && rm -r /usr/lib/glib-2.0
( cd /usr/man/man1 ; rm -f glib-genmarshal.1.gz glib-gettextize.1.gz \
 glib-mkenums.1.gz gobject-query.1.gz )
( cd /usr/share/aclocal ; rm -f glib-2.0.m4 glib-gettext.m4 )
test -d /usr/share/glib-2.0 && rm -r /usr/share/glib-2.0
test -d /usr/share/gtk-doc/html/glib && rm -r /usr/share/gtk-doc/html/glib
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "glib-*" -exec rm -r {} \;
rm -f ~/installed/glib-*.tar.*

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>