2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
5 <refentry id="gtk-building">
7 <refentrytitle>Compiling the GTK+ libraries</refentrytitle>
8 <manvolnum>3</manvolnum>
9 <refmiscinfo>GTK Library</refmiscinfo>
13 <refname>Compiling the GTK+ Libraries</refname>
15 How to compile GTK+ itself
18 <refsect1 id="overview">
19 <title>Building GTK+ on UNIX-like systems</title>
21 This chapter covers building and installing GTK+ on UNIX and
22 UNIX-like systems such as Linux. Compiling GTK+ on Microsoft
23 Windows is different in detail and somewhat more difficult to
24 get going since the necessary tools aren't included with
28 Before we get into the details of how to compile GTK+, we should
29 mention that in many cases, binary packages of GTK+ prebuilt for
30 your operating system will be available, either from your
31 operating system vendor or from independent sources. If such a
32 set of packages is available, installing it will get you
33 programming with GTK+ much faster than building it yourself. In
34 fact, you may well already have GTK+ installed on your system
38 On UNIX-like systems GTK+ uses the standard GNU build system,
39 using <application>autoconf</application> for package
40 configuration and resolving portability issues,
41 <application>automake</application> for building makefiles that
42 comply with the GNU Coding Standards, and
43 <application>libtool</application> for building shared libraries
44 on multiple platforms.
47 If you are building GTK+ from the distributed source packages,
48 then you won't need these tools installed; the necessary pieces
49 of the tools are already included in the source packages. But
50 it's useful to know a bit about how packages that use these
51 tools work. A source package is distributed as a
52 <literal>tar.bz2</literal> or <literal>tar.xz</literal> file
53 which you unpack into a directory full of the source files as follows:
56 tar xvfj gtk+-3.2.0.tar.bz2
57 tar xvfJ gtk+-3.2.0.tar.xz
60 In the toplevel directory that is created, there will be
61 a shell script called <filename>configure</filename> which
62 you then run to take the template makefiles called
63 <filename>Makefile.in</filename> in the package and create
64 makefiles customized for your operating system.
65 The <filename>configure</filename> script can be passed
66 various command line arguments to determine how the package
67 is built and installed. The most commonly useful argument is
68 the <systemitem>--prefix</systemitem> argument which
69 determines where the package is installed. To install a package
70 in <filename>/opt/gtk</filename> you would run configure as:
73 ./configure --prefix=/opt/gtk
76 A full list of options can be found by running
77 <filename>configure</filename> with the
78 <systemitem>--help</systemitem> argument. In general, the defaults are
79 right and should be trusted. After you've run
80 <filename>configure</filename>, you then run the
81 <command>make</command> command to build the package and install
89 If you don't have permission to write to the directory you are
90 installing in, you may have to change to root temporarily before
91 running <literal>make install</literal>. Also, if you are
92 installing in a system directory, on some systems (such as
93 Linux), you will need to run <command>ldconfig</command> after
94 <literal>make install</literal> so that the newly installed
95 libraries will be found.
98 Several environment variables are useful to pass to set before
99 running configure. <envar>CPPFLAGS</envar> contains options to
100 pass to the C compiler, and is used to tell the compiler where
101 to look for include files. The <envar>LDFLAGS</envar> variable
102 is used in a similar fashion for the linker. Finally the
103 <envar>PKG_CONFIG_PATH</envar> environment variable contains
104 a search path that <command>pkg-config</command> (see below)
105 uses when looking for for file describing how to compile
106 programs using different libraries. If you were installing GTK+
107 and it's dependencies into <filename>/opt/gtk</filename>, you
108 might want to set these variables as:
111 CPPFLAGS="-I/opt/gtk/include"
112 LDFLAGS="-L/opt/gtk/lib"
113 PKG_CONFIG_PATH="/opt/gtk/lib/pkgconfig"
114 export CPPFLAGS LDFLAGS PKG_CONFIG_PATH
117 You may also need to set the <envar>LD_LIBRARY_PATH</envar>
118 environment variable so the systems dynamic linker can find
119 the newly installed libraries, and the <envar>PATH</envar>
120 environment program so that utility binaries installed by
121 the various libraries will be found.
124 LD_LIBRARY_PATH="/opt/gtk/lib"
125 PATH="/opt/gtk/bin:$PATH"
126 export LD_LIBRARY_PATH PATH
129 <refsect1 id="dependencies">
130 <title>Dependencies</title>
132 Before you can compile the GTK+ widget toolkit, you need to have
133 various other tools and libraries installed on your
134 system. The two tools needed during the build process (as
135 differentiated from the tools used in when creating GTK+
136 mentioned above such as <application>autoconf</application>)
137 are <command>pkg-config</command> and GNU make.
143 url="http://pkg-config.freedesktop.org">pkg-config</ulink>
144 is a tool for tracking the compilation flags needed for
145 libraries that are used by the GTK+ libraries. (For each
146 library, a small <literal>.pc</literal> text file is installed
147 in a standard location that contains the compilation flags
148 needed for that library along with version number information.)
153 The GTK+ makefiles will mostly work with different versions
154 of <command>make</command>, however, there tends to be
155 a few incompatibilities, so the GTK+ team recommends
156 installing <ulink url="http://www.gnu.org/software/make">GNU
157 make</ulink> if you don't already have it on your system
158 and using it. (It may be called <command>gmake</command>
159 rather than <command>make</command>.)
164 Some of the libraries that GTK+ depends on are maintained by
165 by the GTK+ team: GLib, GdkPixbuf, Pango, and ATK. Other libraries
166 are maintained separately.
171 The GLib library provides core non-graphical functionality
172 such as high level data types, Unicode manipulation, and
173 an object and type system to C programs. It is available
174 from the <ulink url="ftp://ftp.gtk.org/pub/glib/">GTK+
180 <ulink url="http://www.pango.org">Pango</ulink> is a library
181 for internationalized text handling. It is available from
182 the <ulink url="ftp://ftp.gtk.org/pub/pango/">GTK+ FTP
188 ATK is the Accessibility Toolkit. It provides a set of generic
189 interfaces allowing accessibility technologies such as
190 screen readers to interact with a graphical user interface.
191 It is available from the <ulink
192 url="ftp://ftp.gtk.org/pub/atk/">GTK+ FTP site</ulink>.
197 The <ulink url="http://www.gnu.org/software/libiconv/">GNU
198 libiconv library</ulink> is needed to build GLib if your
199 system doesn't have the <function>iconv()</function>
200 function for doing conversion between character
201 encodings. Most modern systems should have
202 <function>iconv()</function>.
207 The libintl library from the <ulink
208 url="http://www.gnu.org/software/gettext/">GNU gettext
209 package</ulink> is needed if your system doesn't have the
210 <function>gettext()</function> functionality for handling
211 message translation databases.
216 The libraries from the X window system are needed to build
217 Pango and GTK+. You should already have these installed on
218 your system, but it's possible that you'll need to install
219 the development environment for these libraries that your
220 operating system vendor provides.
225 The <ulink url="http://www.fontconfig.org">fontconfig</ulink>
226 library provides Pango with a standard way of locating
227 fonts and matching them against font names.
232 <ulink url="http://www.cairographics.org">Cairo</ulink>
233 is a graphics library that supports vector graphics and image
234 compositing. Both Pango and GTK+ use cairo for all of their
240 The GdkPixbuf library provides facilities for loading
241 images in a variety of file formats.
246 <ulink url="http://live.gnome.org/GObjectIntrospection">gobject-introspection</ulink>
247 is a framework for making introspection data available to
253 The <ulink url="http://www.freedesktop.org/wiki/Software/shared-mime-info">shared-mime-info</ulink>
254 package is not a hard dependency of GTK+, but it contains definitions
255 for mime types that are used by GIO and, indirectly, by GTK+.
256 gdk-pixbuf will use GIO for mime type detection if possible. For this
257 to work, shared-mime-info needs to be installed and
258 <envar>XDG_DATA_DIRS</envar> set accordingly at configure time.
259 Otherwise, gdk-pixbuf falls back to its built-in mime type detection.
264 <refsect1 id="building">
265 <title>Building and testing GTK+</title>
267 First make sure that you have the necessary external
268 dependencies installed: <command>pkg-config</command>, GNU make,
269 the JPEG, PNG, and TIFF libraries, FreeType, and, if necessary,
270 libiconv and libintl. To get detailed information about building
271 these packages, see the documentation provided with the
273 On a Linux system, it's quite likely you'll have all of these
274 installed already except for <command>pkg-config</command>.
277 Then build and install the GTK+ libraries in the order:
278 GLib, Pango, ATK, then GTK+. For each library, follow the
279 steps of <literal>configure</literal>, <literal>make</literal>,
280 <literal>make install</literal> mentioned above. If you're
281 lucky, this will all go smoothly, and you'll be ready to
282 <link linkend="gtk-compiling">start compiling your own GTK+
283 applications</link>. You can test your GTK+ installation
284 by running the <command>gtk3-demo</command> program that
288 If one of the <filename>configure</filename> scripts fails or running
289 <command>make</command> fails, look closely at the error
290 messages printed; these will often provide useful information
291 as to what went wrong. When <filename>configure</filename>
292 fails, extra information, such as errors that a test compilation
293 ran into, is found in the file <filename>config.log</filename>.
294 Looking at the last couple of hundred lines in this file will
295 frequently make clear what went wrong. If all else fails, you
296 can ask for help on the gtk-list mailing list.
297 See <xref linkend="gtk-resources"/> for more information.
300 <refsect1 id="extra-configuration-options">
301 <title>Extra Configuration Options</title>
304 In addition to the normal options, the
305 <command>configure</command> script for the GTK+ library
306 supports a number of additional arguments. (Command line
307 arguments for the other GTK+ libraries are described in
308 the documentation distributed with the those libraries.)
311 <command>configure</command>
314 <arg>--disable-modules</arg>
315 <arg>--enable-modules</arg>
319 <arg>--with-included-immodules=MODULE1,MODULE2,...</arg>
323 <arg>--enable-debug=[no/minimum/yes]</arg>
327 <arg>--disable-Bsymbolic</arg>
328 <arg>--enable-Bsymbolic</arg>
332 <arg>--disable-xkb</arg>
333 <arg>--enable-xkb</arg>
337 <arg>--disable-xinerama</arg>
338 <arg>--enable-xinerama</arg>
342 <arg>--disable-gtk-doc</arg>
343 <arg>--enable-gtk-doc</arg>
347 <arg>--disable-cups</arg>
348 <arg>--enable-cups</arg>
352 <arg>--disable-papi</arg>
353 <arg>--enable-papi</arg>
357 <arg>--enable-xinput</arg>
358 <arg>--disable-xinput</arg>
362 <arg>--enable-packagekit</arg>
363 <arg>--disable-packagekit</arg>
367 <arg>--enable-x11-backend</arg>
368 <arg>--disable-x11-backend</arg>
369 <arg>--enable-win32-backend</arg>
370 <arg>--disable-win32-backend</arg>
371 <arg>--enable-quartz-backend</arg>
372 <arg>--disable-quartz-backend</arg>
376 <arg>--enable-introspection=[no/auto/yes]</arg>
380 <arg>--enable-gtk2-dependency</arg>
381 <arg>--disable-gtk2-dependency</arg>
387 <title><systemitem>--disable-modules</systemitem> and
388 <systemitem>--enable-modules</systemitem></title>
391 Normally GTK+ will try to build the input method modules
392 as little shared libraries that are loaded on demand.
393 The <systemitem>--disable-modules</systemitem> argument
394 indicates that they should all be built statically
395 into the GTK+ library instead. This is useful for
396 people who need to produce statically-linked binaries.
397 If neither <systemitem>--disable-modules</systemitem> nor
398 <systemitem>--enable-modules</systemitem> is specified,
399 then the <command>configure</command> script will try to
400 auto-detect whether shared modules work on your system.
405 <title><systemitem>--with-included-immodules</systemitem></title>
408 This option allows you to specify which input method modules you
409 want to include directly into the GTK+ shared library, as opposed
410 to building them as loadable modules.
415 <title><systemitem>--enable-debug</systemitem></title>
418 Turns on various amounts of debugging support. Setting this to
419 'no' disables g_assert(), g_return_if_fail(), g_return_val_if_fail() and all cast checks between different object types. Setting it
420 to 'minimum' disables only cast checks. Setting it to 'yes' enables
421 <link linkend="GTK-Debug-Options">runtime debugging</link>.
422 The default is 'minimum'.
423 Note that 'no' is fast, but dangerous as it tends to destabilize
424 even mostly bug-free software by changing the effect of many bugs
425 from simple warnings into fatal crashes. Thus
426 <option>--enable-debug=no</option> should <emphasis>not</emphasis>
427 be used for stable releases of GTK+.
432 <title><systemitem>--disable-Bsymbolic</systemitem> and
433 <systemitem>--enable-Bsymbolic</systemitem></title>
435 The option <systemitem>--disable-Bsymbolic</systemitem>
436 turns off the use of the -Bsymbolic-functions linker flag.
437 This is only necessary if you want to override GTK+ functions
438 by using <envar>LD_PRELOAD</envar>.
443 <title><systemitem>--enable-explicit-deps</systemitem> and
444 <systemitem>--disable-explicit-deps</systemitem></title>
446 If <systemitem>--enable-explicit-deps</systemitem> is
447 specified then GTK+ will write the full set of libraries
448 that GTK+ depends upon into its <literal>.pc</literal> files to be used when
449 programs depending on GTK+ are linked. Otherwise, GTK+
450 only will include the GTK+ libraries themselves, and
451 will depend on system library dependency facilities to
452 bring in the other libraries.
453 By default GTK+ will disable explicit dependencies unless
454 it detects that they are needed on the system. (If you
455 specify <systemitem>--enable-static</systemitem> to force
456 building of static libraries, then explicit dependencies
457 will be written since library dependencies don't work
458 for static libraries.) Specifying
459 <systemitem>--enable-explicit-deps</systemitem> or
460 <systemitem>--enable-static</systemitem> can cause
462 problems when libraries that GTK+ depends upon change
463 their versions, and should be avoided if possible.
468 <title><systemitem>--disable-xkb</systemitem> and
469 <systemitem>--enable-xkb</systemitem></title>
472 By default the <command>configure</command> script will try
473 to auto-detect whether the XKB extension is supported by
474 the X libraries GTK+ is linked with.
475 These options can be used to explicitly control whether
476 GTK+ will support the XKB extension.
481 <title><systemitem>--disable-xinerama</systemitem> and
482 <systemitem>--enable-xinerama</systemitem></title>
485 By default the <command>configure</command> script will try
486 to link against the Xinerama libraries if they are found.
487 These options can be used to explicitly control whether
488 Xinerama should be used.
493 <title><systemitem>--disable-xinput</systemitem> and
494 <systemitem>--enable-xinput</systemitem></title>
496 Controls whether GTK+ is built with support for the XInput
497 or XInput2 extension. These extensions provide an extended
498 interface to input devices such as graphics tablets.
499 When this support is compiled in, specially written
500 GTK+ programs can get access to subpixel positions,
501 multiple simultaneous input devices, and extra "axes"
502 provided by the device such as pressure and tilt
508 <title><systemitem>--disable-gtk-doc</systemitem> and
509 <systemitem>--enable-gtk-doc</systemitem></title>
512 The <application>gtk-doc</application> package is
513 used to generate the reference documentation included
514 with GTK+. By default support for <application>gtk-doc</application>
515 is disabled because it requires various extra dependencies
516 to be installed. If you have
517 <application>gtk-doc</application> installed and
518 are modifying GTK+, you may want to enable
519 <application>gtk-doc</application> support by passing
520 in <systemitem>--enable-gtk-doc</systemitem>. If not
521 enabled, pre-generated HTML files distributed with GTK+
527 <title><systemitem>--disable-cups</systemitem> and
528 <systemitem>--enable-cups</systemitem></title>
531 By default the <command>configure</command> script will try
532 to build the cups print backend if the cups libraries are found.
533 These options can be used to explicitly control whether
534 the cups print backend should be built.
539 <title><systemitem>--disable-papi</systemitem> and
540 <systemitem>--enable-papi</systemitem></title>
543 By default the <command>configure</command> script will try
544 to build the papi print backend if the papi libraries are found.
545 These options can be used to explicitly control whether
546 the papi print backend should be built.
551 <title><systemitem>--disable-packagekit</systemitem> and
552 <systemitem>--enable-packagekit</systemitem></title>
554 By default the <command>configure</command> script will try
555 to build the PackageKit support for the open-with dialog if
556 the PackageKit libraries are found.
557 These options can be used to explicitly control whether
558 PackageKit support should be built.
563 <title><systemitem>--enable-x11-backend</systemitem>,
564 <systemitem>--disable-x11-backend</systemitem>,
565 <systemitem>--enable-win32-backend</systemitem>,
566 <systemitem>--disable-win32-backend</systemitem>,
567 <systemitem>--enable-quartz-backend</systemitem>,
568 and <systemitem>--disable-quartz-backend</systemitem></title>
571 Enables specific backends for GDK. If none of these options
572 are given, the x11 backend will be enabled by default,
573 unless the platform is Windows, in which case the default is
574 win32. If any backend is explicitly enabled or disabled, no
575 other platform will be enabled automatically. Other
576 supported backends are the quartz backend for OS X.
581 <title><systemitem>--enable-introspection</systemitem></title>
584 Build with or without introspection support.
585 The default is 'auto'.
590 <title><systemitem>--enable-gtk2-dependency</systemitem> or
591 <systemitem>--disable-gtk2-dependency</systemitem></title>
594 Whether to rely on an exiting gtk-update-icon-cache utility
595 instead of building our own. Distributions which are shipping
596 both GTK+ 2.x and GTK+ 3 may want to use this option to
597 avoid file conflicts between these packages.
598 The default is to build gtk-update-icon-cache.
605 <!-- Local Variables: -->
606 <!-- sgml-parent-document: ("gtk-docs.sgml" "chapter" "refentry") -->