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, ATK and GObject Introspection.
166 Other libraries 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="http://ftp.gtk.org/pub/glib/">GTK+
176 <ulink url="http://download.gnome.org/sources/glib/">here</ulink>.
181 The <ulink url="http://git.gnome.org/browse/gdk-pixbuf/">GdkPixbuf library</ulink>
182 provides facilities for loading images in a variety of file formats.
184 <ulink url="http://download.gnome.org/sources/gdk-pixbuf/">here</ulink>.
189 <ulink url="http://www.pango.org">Pango</ulink> is a library
190 for internationalized text handling. It is available
191 <ulink url="http://download.gnome.org/sources/pango/">here</ulink>.
196 ATK is the Accessibility Toolkit. It provides a set of generic
197 interfaces allowing accessibility technologies such as
198 screen readers to interact with a graphical user interface.
200 <ulink url="http://download.gnome.org/sources/atk/">here</ulink>.
205 <ulink url="http://live.gnome.org/GObjectIntrospection">Gobject Introspection</ulink>
206 is a framework for making introspection data available to
207 language bindings. It is available
208 <ulink url="http://download.gnome.org/sources/gobject-introspection/">here</ulink>.
213 <title>External dependencies</title>
216 The <ulink url="http://www.gnu.org/software/libiconv/">GNU
217 libiconv library</ulink> is needed to build GLib if your
218 system doesn't have the <function>iconv()</function>
219 function for doing conversion between character
220 encodings. Most modern systems should have
221 <function>iconv()</function>.
226 The libintl library from the <ulink
227 url="http://www.gnu.org/software/gettext/">GNU gettext
228 package</ulink> is needed if your system doesn't have the
229 <function>gettext()</function> functionality for handling
230 message translation databases.
235 The libraries from the X window system are needed to build
236 Pango and GTK+. You should already have these installed on
237 your system, but it's possible that you'll need to install
238 the development environment for these libraries that your
239 operating system vendor provides.
244 The <ulink url="http://www.fontconfig.org">fontconfig</ulink>
245 library provides Pango with a standard way of locating
246 fonts and matching them against font names.
251 <ulink url="http://www.cairographics.org">Cairo</ulink>
252 is a graphics library that supports vector graphics and image
253 compositing. Both Pango and GTK+ use cairo for all of their
259 The <ulink url="http://www.freedesktop.org/wiki/Software/shared-mime-info">shared-mime-info</ulink>
260 package is not a hard dependency of GTK+, but it contains definitions
261 for mime types that are used by GIO and, indirectly, by GTK+.
262 gdk-pixbuf will use GIO for mime type detection if possible. For this
263 to work, shared-mime-info needs to be installed and
264 <envar>XDG_DATA_DIRS</envar> set accordingly at configure time.
265 Otherwise, gdk-pixbuf falls back to its built-in mime type detection.
270 <refsect1 id="building">
271 <title>Building and testing GTK+</title>
273 First make sure that you have the necessary external
274 dependencies installed: <command>pkg-config</command>, GNU make,
275 the JPEG, PNG, and TIFF libraries, FreeType, and, if necessary,
276 libiconv and libintl. To get detailed information about building
277 these packages, see the documentation provided with the
279 On a Linux system, it's quite likely you'll have all of these
280 installed already except for <command>pkg-config</command>.
283 Then build and install the GTK+ libraries in the order:
284 GLib, Pango, ATK, then GTK+. For each library, follow the
285 steps of <literal>configure</literal>, <literal>make</literal>,
286 <literal>make install</literal> mentioned above. If you're
287 lucky, this will all go smoothly, and you'll be ready to
288 <link linkend="gtk-compiling">start compiling your own GTK+
289 applications</link>. You can test your GTK+ installation
290 by running the <command>gtk3-demo</command> program that
294 If one of the <filename>configure</filename> scripts fails or running
295 <command>make</command> fails, look closely at the error
296 messages printed; these will often provide useful information
297 as to what went wrong. When <filename>configure</filename>
298 fails, extra information, such as errors that a test compilation
299 ran into, is found in the file <filename>config.log</filename>.
300 Looking at the last couple of hundred lines in this file will
301 frequently make clear what went wrong. If all else fails, you
302 can ask for help on the gtk-list mailing list.
303 See <xref linkend="gtk-resources"/> for more information.
306 <refsect1 id="extra-configuration-options">
307 <title>Extra Configuration Options</title>
310 In addition to the normal options, the
311 <command>configure</command> script for the GTK+ library
312 supports a number of additional arguments. (Command line
313 arguments for the other GTK+ libraries are described in
314 the documentation distributed with the those libraries.)
317 <command>configure</command>
320 <arg>--disable-modules</arg>
321 <arg>--enable-modules</arg>
325 <arg>--with-included-immodules=MODULE1,MODULE2,...</arg>
329 <arg>--enable-debug=[no/minimum/yes]</arg>
333 <arg>--disable-Bsymbolic</arg>
334 <arg>--enable-Bsymbolic</arg>
338 <arg>--disable-xkb</arg>
339 <arg>--enable-xkb</arg>
343 <arg>--disable-xinerama</arg>
344 <arg>--enable-xinerama</arg>
348 <arg>--disable-gtk-doc</arg>
349 <arg>--enable-gtk-doc</arg>
353 <arg>--disable-cups</arg>
354 <arg>--enable-cups</arg>
358 <arg>--disable-papi</arg>
359 <arg>--enable-papi</arg>
363 <arg>--enable-xinput</arg>
364 <arg>--disable-xinput</arg>
368 <arg>--enable-packagekit</arg>
369 <arg>--disable-packagekit</arg>
373 <arg>--enable-x11-backend</arg>
374 <arg>--disable-x11-backend</arg>
375 <arg>--enable-win32-backend</arg>
376 <arg>--disable-win32-backend</arg>
377 <arg>--enable-quartz-backend</arg>
378 <arg>--disable-quartz-backend</arg>
382 <arg>--enable-introspection=[no/auto/yes]</arg>
386 <arg>--enable-gtk2-dependency</arg>
387 <arg>--disable-gtk2-dependency</arg>
393 <title><systemitem>--disable-modules</systemitem> and
394 <systemitem>--enable-modules</systemitem></title>
397 Normally GTK+ will try to build the input method modules
398 as little shared libraries that are loaded on demand.
399 The <systemitem>--disable-modules</systemitem> argument
400 indicates that they should all be built statically
401 into the GTK+ library instead. This is useful for
402 people who need to produce statically-linked binaries.
403 If neither <systemitem>--disable-modules</systemitem> nor
404 <systemitem>--enable-modules</systemitem> is specified,
405 then the <command>configure</command> script will try to
406 auto-detect whether shared modules work on your system.
411 <title><systemitem>--with-included-immodules</systemitem></title>
414 This option allows you to specify which input method modules you
415 want to include directly into the GTK+ shared library, as opposed
416 to building them as loadable modules.
421 <title><systemitem>--enable-debug</systemitem></title>
424 Turns on various amounts of debugging support. Setting this to
425 'no' disables g_assert(), g_return_if_fail(), g_return_val_if_fail() and all cast checks between different object types. Setting it
426 to 'minimum' disables only cast checks. Setting it to 'yes' enables
427 <link linkend="GTK-Debug-Options">runtime debugging</link>.
428 The default is 'minimum'.
429 Note that 'no' is fast, but dangerous as it tends to destabilize
430 even mostly bug-free software by changing the effect of many bugs
431 from simple warnings into fatal crashes. Thus
432 <option>--enable-debug=no</option> should <emphasis>not</emphasis>
433 be used for stable releases of GTK+.
438 <title><systemitem>--disable-Bsymbolic</systemitem> and
439 <systemitem>--enable-Bsymbolic</systemitem></title>
441 The option <systemitem>--disable-Bsymbolic</systemitem>
442 turns off the use of the -Bsymbolic-functions linker flag.
443 This is only necessary if you want to override GTK+ functions
444 by using <envar>LD_PRELOAD</envar>.
449 <title><systemitem>--enable-explicit-deps</systemitem> and
450 <systemitem>--disable-explicit-deps</systemitem></title>
452 If <systemitem>--enable-explicit-deps</systemitem> is
453 specified then GTK+ will write the full set of libraries
454 that GTK+ depends upon into its <literal>.pc</literal> files to be used when
455 programs depending on GTK+ are linked. Otherwise, GTK+
456 only will include the GTK+ libraries themselves, and
457 will depend on system library dependency facilities to
458 bring in the other libraries.
459 By default GTK+ will disable explicit dependencies unless
460 it detects that they are needed on the system. (If you
461 specify <systemitem>--enable-static</systemitem> to force
462 building of static libraries, then explicit dependencies
463 will be written since library dependencies don't work
464 for static libraries.) Specifying
465 <systemitem>--enable-explicit-deps</systemitem> or
466 <systemitem>--enable-static</systemitem> can cause
468 problems when libraries that GTK+ depends upon change
469 their versions, and should be avoided if possible.
474 <title><systemitem>--disable-xkb</systemitem> and
475 <systemitem>--enable-xkb</systemitem></title>
478 By default the <command>configure</command> script will try
479 to auto-detect whether the XKB extension is supported by
480 the X libraries GTK+ is linked with.
481 These options can be used to explicitly control whether
482 GTK+ will support the XKB extension.
487 <title><systemitem>--disable-xinerama</systemitem> and
488 <systemitem>--enable-xinerama</systemitem></title>
491 By default the <command>configure</command> script will try
492 to link against the Xinerama libraries if they are found.
493 These options can be used to explicitly control whether
494 Xinerama should be used.
499 <title><systemitem>--disable-xinput</systemitem> and
500 <systemitem>--enable-xinput</systemitem></title>
502 Controls whether GTK+ is built with support for the XInput
503 or XInput2 extension. These extensions provide an extended
504 interface to input devices such as graphics tablets.
505 When this support is compiled in, specially written
506 GTK+ programs can get access to subpixel positions,
507 multiple simultaneous input devices, and extra "axes"
508 provided by the device such as pressure and tilt
514 <title><systemitem>--disable-gtk-doc</systemitem> and
515 <systemitem>--enable-gtk-doc</systemitem></title>
518 The <application>gtk-doc</application> package is
519 used to generate the reference documentation included
520 with GTK+. By default support for <application>gtk-doc</application>
521 is disabled because it requires various extra dependencies
522 to be installed. If you have
523 <application>gtk-doc</application> installed and
524 are modifying GTK+, you may want to enable
525 <application>gtk-doc</application> support by passing
526 in <systemitem>--enable-gtk-doc</systemitem>. If not
527 enabled, pre-generated HTML files distributed with GTK+
533 <title><systemitem>--disable-cups</systemitem> and
534 <systemitem>--enable-cups</systemitem></title>
537 By default the <command>configure</command> script will try
538 to build the cups print backend if the cups libraries are found.
539 These options can be used to explicitly control whether
540 the cups print backend should be built.
545 <title><systemitem>--disable-papi</systemitem> and
546 <systemitem>--enable-papi</systemitem></title>
549 By default the <command>configure</command> script will try
550 to build the papi print backend if the papi libraries are found.
551 These options can be used to explicitly control whether
552 the papi print backend should be built.
557 <title><systemitem>--disable-packagekit</systemitem> and
558 <systemitem>--enable-packagekit</systemitem></title>
560 By default the <command>configure</command> script will try
561 to build the PackageKit support for the open-with dialog if
562 the PackageKit libraries are found.
563 These options can be used to explicitly control whether
564 PackageKit support should be built.
569 <title><systemitem>--enable-x11-backend</systemitem>,
570 <systemitem>--disable-x11-backend</systemitem>,
571 <systemitem>--enable-win32-backend</systemitem>,
572 <systemitem>--disable-win32-backend</systemitem>,
573 <systemitem>--enable-quartz-backend</systemitem>,
574 and <systemitem>--disable-quartz-backend</systemitem></title>
577 Enables specific backends for GDK. If none of these options
578 are given, the x11 backend will be enabled by default,
579 unless the platform is Windows, in which case the default is
580 win32. If any backend is explicitly enabled or disabled, no
581 other platform will be enabled automatically. Other
582 supported backends are the quartz backend for OS X.
587 <title><systemitem>--enable-introspection</systemitem></title>
590 Build with or without introspection support.
591 The default is 'auto'.
596 <title><systemitem>--enable-gtk2-dependency</systemitem> or
597 <systemitem>--disable-gtk2-dependency</systemitem></title>
600 Whether to rely on an exiting gtk-update-icon-cache utility
601 instead of building our own. Distributions which are shipping
602 both GTK+ 2.x and GTK+ 3 may want to use this option to
603 avoid file conflicts between these packages.
604 The default is to build gtk-update-icon-cache.
611 <!-- Local Variables: -->
612 <!-- sgml-parent-document: ("gtk-docs.sgml" "chapter" "refentry") -->