Initial packaging to sync OBS with git/gerrit
[profile/ivi/gtk3.git] / docs / reference / gtk / building.sgml
1 <?xml version="1.0"?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3                "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
4 ]>
5 <refentry id="gtk-building">
6 <refmeta>
7 <refentrytitle>Compiling the GTK+ libraries</refentrytitle>
8 <manvolnum>3</manvolnum>
9 <refmiscinfo>GTK Library</refmiscinfo>
10 </refmeta>
11
12 <refnamediv>
13 <refname>Compiling the GTK+ Libraries</refname>
14 <refpurpose>
15 How to compile GTK+ itself
16 </refpurpose>
17 </refnamediv>
18   <refsect1 id="overview">
19     <title>Building GTK+ on UNIX-like systems</title>
20     <para>
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
25       the operating system.
26     </para>
27     <para>
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
35       already.
36     </para>
37     <para>
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.
45     </para>
46     <para>
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:
54     </para>
55     <programlisting>
56       tar xvfj gtk+-3.2.0.tar.bz2
57       tar xvfJ gtk+-3.2.0.tar.xz
58     </programlisting>
59     <para>
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:
71     </para>
72     <programlisting>
73       ./configure --prefix=/opt/gtk
74     </programlisting>
75     <para>
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
82       it.
83     </para>
84     <programlisting>
85       make
86       make install
87     </programlisting>
88     <para>
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.
96     </para>
97     <para>
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:
109     </para>
110     <programlisting>
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
115     </programlisting>
116     <para>
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.
122     </para>
123     <programlisting>
124       LD_LIBRARY_PATH="/opt/gtk/lib"
125       PATH="/opt/gtk/bin:$PATH"
126       export LD_LIBRARY_PATH PATH
127     </programlisting>
128   </refsect1>
129   <refsect1 id="dependencies">
130     <title>Dependencies</title>
131     <para>
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.
138     </para>
139     <itemizedlist>
140       <listitem>
141         <para>
142           <ulink
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.)
149         </para>
150       </listitem>
151       <listitem>
152         <para>
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>.)
160         </para>
161       </listitem>
162     </itemizedlist>
163     <para>
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.
167     </para>
168     <itemizedlist>
169       <listitem>
170         <para>
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+
175           FTP site</ulink> or
176           <ulink url="http://download.gnome.org/sources/glib/">here</ulink>.
177         </para>
178       </listitem>
179       <listitem>
180         <para>
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.
183           It is available
184           <ulink url="http://download.gnome.org/sources/gdk-pixbuf/">here</ulink>.
185         </para>
186       </listitem>
187       <listitem>
188         <para>
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>.
192         </para>
193       </listitem>
194       <listitem>
195         <para>
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.
199           It is available
200           <ulink url="http://download.gnome.org/sources/atk/">here</ulink>.
201         </para>
202       </listitem>
203       <listitem>
204         <para>
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>.
209         </para>
210       </listitem>
211     </itemizedlist>
212     <itemizedlist>
213       <title>External dependencies</title>
214       <listitem>
215         <para>
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>.
222         </para>
223       </listitem>
224       <listitem>
225         <para>
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.
231         </para>
232       </listitem>
233       <listitem>
234         <para>
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.
240         </para>
241       </listitem>
242       <listitem>
243         <para>
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.
247         </para>
248       </listitem>
249       <listitem>
250         <para>
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
254           drawing.
255         </para>
256       </listitem>
257       <listitem>
258         <para>
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.
266         </para>
267       </listitem>
268     </itemizedlist>
269   </refsect1>
270   <refsect1 id="building">
271     <title>Building and testing GTK+</title>
272     <para>
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
278       individual packages.
279       On a Linux system, it's quite likely you'll have all of these
280       installed already except for <command>pkg-config</command>.
281     </para>
282     <para>
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
291       GTK+ installs.
292     </para>
293     <para>
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.
304     </para>
305   </refsect1>
306       <refsect1 id="extra-configuration-options">
307       <title>Extra Configuration Options</title>
308
309       <para>
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.)
315
316         <cmdsynopsis>
317           <command>configure</command>
318           <sbr/>
319           <group>
320             <arg>--disable-modules</arg>
321             <arg>--enable-modules</arg>
322           </group>
323           <sbr/>
324           <group>
325             <arg>--with-included-immodules=MODULE1,MODULE2,...</arg>
326           </group>
327           <sbr/>
328           <group>
329             <arg>--enable-debug=[no/minimum/yes]</arg>
330           </group>
331           <sbr/>
332           <group>
333             <arg>--disable-Bsymbolic</arg>
334             <arg>--enable-Bsymbolic</arg>
335           </group>
336           <sbr/>
337           <group>
338             <arg>--disable-xkb</arg>
339             <arg>--enable-xkb</arg>
340           </group>
341           <sbr/>
342           <group>
343             <arg>--disable-xinerama</arg>
344             <arg>--enable-xinerama</arg>
345           </group>
346           <sbr/>
347           <group>
348             <arg>--disable-gtk-doc</arg>
349             <arg>--enable-gtk-doc</arg>
350           </group>
351           <sbr/>
352           <group>
353             <arg>--disable-cups</arg>
354             <arg>--enable-cups</arg>
355           </group>
356           <sbr/>
357           <group>
358             <arg>--disable-papi</arg>
359             <arg>--enable-papi</arg>
360           </group>
361           <sbr/>
362           <group>
363             <arg>--enable-xinput</arg>
364             <arg>--disable-xinput</arg>
365           </group>
366           <sbr/>
367           <group>
368             <arg>--enable-packagekit</arg>
369             <arg>--disable-packagekit</arg>
370           </group>
371           <sbr/>
372           <group>
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>
379           </group>
380           <sbr/>
381           <group>
382             <arg>--enable-introspection=[no/auto/yes]</arg>
383           </group>
384           <sbr/>
385           <group>
386             <arg>--enable-gtk2-dependency</arg>
387             <arg>--disable-gtk2-dependency</arg>
388           </group>
389         </cmdsynopsis>
390       </para>
391
392       <formalpara>
393         <title><systemitem>--disable-modules</systemitem> and
394           <systemitem>--enable-modules</systemitem></title>
395
396         <para>
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.
407         </para>
408       </formalpara>
409
410       <formalpara>
411         <title><systemitem>--with-included-immodules</systemitem></title>
412
413         <para>
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.
417         </para>
418       </formalpara>
419
420       <formalpara>
421         <title><systemitem>--enable-debug</systemitem></title>
422
423         <para>
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+.
434         </para>
435       </formalpara>
436
437       <formalpara>
438         <title><systemitem>--disable-Bsymbolic</systemitem> and
439           <systemitem>--enable-Bsymbolic</systemitem></title>
440         <para>
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>.
445         </para>
446       </formalpara>
447
448       <formalpara>
449         <title><systemitem>--enable-explicit-deps</systemitem> and
450           <systemitem>--disable-explicit-deps</systemitem></title>
451         <para>
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
467           compatibility
468           problems when libraries that GTK+ depends upon change
469           their versions, and should be avoided if possible.
470         </para>
471       </formalpara>
472
473       <formalpara>
474         <title><systemitem>--disable-xkb</systemitem> and
475           <systemitem>--enable-xkb</systemitem></title>
476
477         <para>
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.
483         </para>
484       </formalpara>
485
486       <formalpara>
487         <title><systemitem>--disable-xinerama</systemitem> and
488           <systemitem>--enable-xinerama</systemitem></title>
489
490         <para>
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.
495         </para>
496       </formalpara>
497
498       <formalpara>
499         <title><systemitem>--disable-xinput</systemitem> and
500            <systemitem>--enable-xinput</systemitem></title>
501         <para>
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
509           information.
510         </para>
511       </formalpara>
512
513       <formalpara>
514         <title><systemitem>--disable-gtk-doc</systemitem> and
515           <systemitem>--enable-gtk-doc</systemitem></title>
516
517         <para>
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+
528           will be installed.
529         </para>
530       </formalpara>
531
532       <formalpara>
533         <title><systemitem>--disable-cups</systemitem> and
534           <systemitem>--enable-cups</systemitem></title>
535
536         <para>
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.
541         </para>
542       </formalpara>
543
544       <formalpara>
545         <title><systemitem>--disable-papi</systemitem> and
546           <systemitem>--enable-papi</systemitem></title>
547
548         <para>
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.
553         </para>
554       </formalpara>
555
556       <formalpara>
557         <title><systemitem>--disable-packagekit</systemitem> and
558            <systemitem>--enable-packagekit</systemitem></title>
559         <para>
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.
565         </para>
566       </formalpara>
567
568       <formalpara>
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>
575
576         <para>
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.
583         </para>
584       </formalpara>
585
586       <formalpara>
587         <title><systemitem>--enable-introspection</systemitem></title>
588
589         <para>
590           Build with or without introspection support.
591           The default is 'auto'.
592         </para>
593       </formalpara>
594
595       <formalpara>
596         <title><systemitem>--enable-gtk2-dependency</systemitem> or
597            <systemitem>--disable-gtk2-dependency</systemitem></title>
598
599         <para>
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.
605         </para>
606       </formalpara>
607     </refsect1>
608
609 </refentry>
610
611 <!-- Local Variables: -->
612 <!-- sgml-parent-document: ("gtk-docs.sgml" "chapter" "refentry")  -->
613 <!-- End: -->