Compiling the GTK+ libraries
Compiling the GTK+ Libraries ― How to compile GTK+ itself
|
tar.gz
or
tar.bz2
file which you unpack into a directory full of the source files as follows:
tar xvfz gtk+-2.0.0.tar.gz
tar xvfj gtk+-2.0.0.tar.bz2
configure
which you then run to take the template makefiles called
Makefile.in
in the package and create makefiles customized for your operating system. The
configure
script can be passed various command line arguments to determine how the package is built and installed. The most commonly useful argument is the
--prefix
argument which determines where the package is installed. To install a package in
/opt/gtk
you would run configure as:
./configure --prefix=/opt/gtk
configure
with the
--help
argument. In general, the defaults are right and should be trusted. After you've run
configure
, you then run the
make command to build the package and install it.
make
make install
make install
. Also, if you are installing in a system directory, on some systems (such as Linux), you will need to run
ldconfig after
make install
so that the newly installed libraries will be found.
CPPFLAGS
contains options to pass to the C compiler, and is used to tell the compiler where to look for include files. The
LDFLAGS
variable is used in a similar fashion for the linker. Finally the
PKG_CONFIG_PATH
environment variable contains a search path that
pkg-config (see below) uses when looking for for file describing how to compile programs using different libraries. If you were installing GTK+ and it's dependencies into
/opt/gtk
, you might want to set these variables as:
CPPFLAGS="-I/opt/gtk/include"
LDFLAGS="-L/opt/gtk/lib"
PKG_CONFIG_PATH="/opt/gtk/lib/pkgconfig"
export CPPFLAGS LDFLAGS PKG_CONFIG_PATH
LD_LIBRARY_PATH
environment variable so the systems dynamic linker can find the newly installed libraries, and the
PATH
environment program so that utility binaries installed by the various libraries will be found.
LD_LIBRARY_PATH="/opt/gtk/lib"
PATH="/opt/gtk/bin:$PATH"
export LD_LIBRARY_PATH PATH
.pc
text file is installed in a standard location that contains the compilation flags needed for that library along with version number information.) The version of
pkg-config needed to build GTK+ is mirrored in the
dependencies
directory on the GTK+ FTP site.
iconv()
function for doing conversion between character encodings. Most modern systems should have
iconv()
.
gettext()
functionality for handling message translation databases.
dependencies
directory on the the GTK+ FTP site.. (Before installing these libraries from source, you should check if your operating system vendor has prebuilt packages of these libraries that you don't have installed.)
configure
,
make
,
make install
mentioned above. If you're lucky, this will all go smoothly, and you'll be ready to start compiling your own GTK+ applications. You can test your GTK+ installation by running the
gtk-demo program that GTK+ installs.
configure
scripts fails or running
make fails, look closely at the error messages printed; these will often provide useful information as to what went wrong. When
configure
fails, extra information, such as errors that a test compilation ran into, is found in the file
config.log
. Looking at the last couple of hundred lines in this file will frequently make clear what went wrong. If all else fails, you can ask for help on the gtk-list mailing list. See
Mailing lists and bug reports(3) for more information.
configure
[[--disable-modules] | [--enable-modules]] [[--with-included-loaders==LOADER1,LOADER2,...]] [[--with-included-immodules=MODULE1,MODULE2,...]] [[--enable-debug=[no|minimum|yes]]] [[--disable-visibility] | [--enable-visibility]] [[--disable-shm] | [--enable-shm]] [[--disable-xim] | [--enable-xim]] [[--disable-xim-inst] | [--enable-xim-inst]] [[--disable-xkb] | [--enable-xkb]] [[--disable-xinerama] | [--enable-xinerama]] [[--disable-gtk-doc] | [--enable-gtk-doc]] [[--disable-cups] | [--enable-cups]] [[--with-xinput=[no|yes]]] [[--with-gdktarget=[x11|win32|quartz|directfb]]]
--disable-modules
and --enable-modules
. Normally GTK+ will try to build the GdkPixbuf image file format loaders as little shared libraries that are loaded on demand. The
--disable-modules
argument indicates that they should all be built statically into the GTK+ library instead. This is useful for people who need to produce statically-linked binaries. If neither
--disable-modules
nor
--enable-modules
is specified, then the
configure script will try to auto-detect whether shared modules work on your system.
--with-included-loaders
. This option allows you to specify which image loaders you want to include; for example, you might include only the PNG loader to create a smaller GdkPixbuf binary.
--with-included-immodules
. This option allows you to specify which input method modules you want to include.
--enable-debug
. Turns on various amounts of debugging support. Setting this to 'no' disables g_assert(), g_return_if_fail(), g_return_val_if_fail() and all cast checks between different object types. Setting it to 'minimum' disables only cast checks. Setting it to 'yes' enables runtime debugging. The default is 'minimum'. Note that 'no' is fast, but dangerous as it tends to destabilize even mostly bug-free software by changing the effect of many bugs from simple warnings into fatal crashes. Thus
--enable-debug=no
should
not be used for stable releases of GTK+.
--disable-visibility
and --enable-visibility
. The option
--disable-visibility
turns off the use of ELF visibility attributes for linking optimizations. This makes sense while changing GTK+ itself, since the way in which GTK+ uses visibility attributes forces a full rebuild of all source files for any header modification.
--enable-explicit-deps
and --disable-explicit-deps
. If
--enable-explicit-deps
is specified then GTK+ will write the full set of libraries that GTK+ depends upon into its
.pc
files to be used when programs depending on GTK+ are linked. Otherwise, GTK+ only will include the GTK+ libraries themselves, and will depend on system library dependency facilities to bring in the other libraries. By default GTK+ will disable explicit dependencies unless it detects that they are needed on the system. (If you specify
--enable-static
to force building of static libraries, then explicit dependencies will be written since library dependencies don't work for static libraries.) Specifying
--enable-explicit-deps
or
--enable-static
can cause compatibility problems when libraries that GTK+ depends upon change their versions, and should be avoided if possible.
--disable-shm
and --enable-shm
. These options can be used to control whether GTK+ will use shared memory to communicate with the X server when possible. The default is 'yes'.
--disable-xim
and --enable-xim
. These options can be used to control whether GTK+ will be compiled with support for XIM. (The X Input Method extension, used for Japanese input.) The default is yes.
--disable-xim-inst
and --enable-xim-inst
. These options determine whether GTK+ will use the XIM instantiate callback. The default is 'yes', unless the host system is Solaris, where
XRegisterIMInstantiateCallback()
seems to cause a segfault.
--disable-xkb
and --enable-xkb
. By default the
configure script will try to auto-detect whether the XKB extension is supported by the X libraries GTK+ is linked with. These options can be used to explicitly control whether GTK+ will support the XKB extension.
--disable-xinerama
and --enable-xinerama
. By default the
configure script will try to link against the Xinerama libraries if they are found. These options can be used to explicitly control whether Xinerama should be used.
--disable-gtk-doc
and --enable-gtk-doc
. The
gtk-doc package is used to generate the reference documentation included with GTK+. By default support for
gtk-doc is disabled because it requires various extra dependencies to be installed. If you have
gtk-doc installed and are modifying GTK+, you may want to enable
gtk-doc support by passing in
--enable-gtk-doc
. If not enabled, pre-generated HTML files distributed with GTK+ will be installed.
--disable-cups
and --enable-cups
. By default the
configure script will try to build the cups print backend if the cups libraries are found. These options can be used to explicitly control whether the cups print backend should be built.
--with-xinput
. Controls whether GTK+ is built with support for the XInput extension. The XInput extension provides an interface to extended input devices such as graphics tablets. When this support is compiled in, specially written GTK+ programs can get access to subpixel positions, multiple simultaneous input devices, and extra "axes" provided by the device such as pressure and tilt information. This is only known to work well on XFree86 systems, though other systems do have this extension.
--with-gdktarget
. Toggles between the supported backends for GDK. The default is x11, unless the platform is Windows, in which case the default is win32. Other supported backends are the quartz backend for OS X, and the DirectFB backend for the Linux framebuffer.