]> Pileus Git - ~andy/gtk/blob - docs/reference/gtk/building.sgml
docs: building: gz is not used anymore, but xz instead
[~andy/gtk] / 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, and ATK. Other libraries
166       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="ftp://ftp.gtk.org/pub/glib/">GTK+
175           FTP site</ulink>.
176         </para>
177       </listitem>
178       <listitem>
179         <para>
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
183           site</ulink>.
184         </para>
185       </listitem>
186       <listitem>
187         <para>
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>.
193         </para>
194       </listitem>
195       <listitem>
196         <para>
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>.
203         </para>
204       </listitem>
205       <listitem>
206         <para>
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.
212         </para>
213       </listitem>
214       <listitem>
215         <para>
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.
221         </para>
222       </listitem>
223       <listitem>
224         <para>
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.
228         </para>
229       </listitem>
230       <listitem>
231         <para>
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
235           drawing.
236         </para>
237       </listitem>
238       <listitem>
239         <para>
240           The GdkPixbuf library provides facilities for loading
241           images in a variety of file formats.
242         </para>
243       </listitem>
244       <listitem>
245         <para>
246           <ulink url="http://live.gnome.org/GObjectIntrospection">gobject-introspection</ulink>
247           is a framework for making introspection data available to
248           language bindings.
249         </para>
250       </listitem>
251       <listitem>
252         <para>
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.
260         </para>
261       </listitem>
262     </itemizedlist>
263   </refsect1>
264   <refsect1 id="building">
265     <title>Building and testing GTK+</title>
266     <para>
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
272       individual packages.
273       On a Linux system, it's quite likely you'll have all of these
274       installed already except for <command>pkg-config</command>.
275     </para>
276     <para>
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
285       GTK+ installs.
286     </para>
287     <para>
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.
298     </para>
299   </refsect1>
300       <refsect1 id="extra-configuration-options">
301       <title>Extra Configuration Options</title>
302
303       <para>
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.)
309
310         <cmdsynopsis>
311           <command>configure</command>
312           <sbr/>
313           <group>
314             <arg>--disable-modules</arg>
315             <arg>--enable-modules</arg>
316           </group>
317           <sbr/>
318           <group>
319             <arg>--with-included-immodules=MODULE1,MODULE2,...</arg>
320           </group>
321           <sbr/>
322           <group>
323             <arg>--enable-debug=[no/minimum/yes]</arg>
324           </group>
325           <sbr/>
326           <group>
327             <arg>--disable-Bsymbolic</arg>
328             <arg>--enable-Bsymbolic</arg>
329           </group>
330           <sbr/>
331           <group>
332             <arg>--disable-xkb</arg>
333             <arg>--enable-xkb</arg>
334           </group>
335           <sbr/>
336           <group>
337             <arg>--disable-xinerama</arg>
338             <arg>--enable-xinerama</arg>
339           </group>
340           <sbr/>
341           <group>
342             <arg>--disable-gtk-doc</arg>
343             <arg>--enable-gtk-doc</arg>
344           </group>
345           <sbr/>
346           <group>
347             <arg>--disable-cups</arg>
348             <arg>--enable-cups</arg>
349           </group>
350           <sbr/>
351           <group>
352             <arg>--disable-papi</arg>
353             <arg>--enable-papi</arg>
354           </group>
355           <sbr/>
356           <group>
357             <arg>--enable-xinput</arg>
358             <arg>--disable-xinput</arg>
359           </group>
360           <sbr/>
361           <group>
362             <arg>--enable-packagekit</arg>
363             <arg>--disable-packagekit</arg>
364           </group>
365           <sbr/>
366           <group>
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>
373           </group>
374           <sbr/>
375           <group>
376             <arg>--enable-introspection=[no/auto/yes]</arg>
377           </group>
378           <sbr/>
379           <group>
380             <arg>--enable-gtk2-dependency</arg>
381             <arg>--disable-gtk2-dependency</arg>
382           </group>
383         </cmdsynopsis>
384       </para>
385
386       <formalpara>
387         <title><systemitem>--disable-modules</systemitem> and
388           <systemitem>--enable-modules</systemitem></title>
389
390         <para>
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.
401         </para>
402       </formalpara>
403
404       <formalpara>
405         <title><systemitem>--with-included-immodules</systemitem></title>
406
407         <para>
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.
411         </para>
412       </formalpara>
413
414       <formalpara>
415         <title><systemitem>--enable-debug</systemitem></title>
416
417         <para>
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+.
428         </para>
429       </formalpara>
430
431       <formalpara>
432         <title><systemitem>--disable-Bsymbolic</systemitem> and
433           <systemitem>--enable-Bsymbolic</systemitem></title>
434         <para>
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>.
439         </para>
440       </formalpara>
441
442       <formalpara>
443         <title><systemitem>--enable-explicit-deps</systemitem> and
444           <systemitem>--disable-explicit-deps</systemitem></title>
445         <para>
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
461           compatibility
462           problems when libraries that GTK+ depends upon change
463           their versions, and should be avoided if possible.
464         </para>
465       </formalpara>
466
467       <formalpara>
468         <title><systemitem>--disable-xkb</systemitem> and
469           <systemitem>--enable-xkb</systemitem></title>
470
471         <para>
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.
477         </para>
478       </formalpara>
479
480       <formalpara>
481         <title><systemitem>--disable-xinerama</systemitem> and
482           <systemitem>--enable-xinerama</systemitem></title>
483
484         <para>
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.
489         </para>
490       </formalpara>
491
492       <formalpara>
493         <title><systemitem>--disable-xinput</systemitem> and
494            <systemitem>--enable-xinput</systemitem></title>
495         <para>
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
503           information.
504         </para>
505       </formalpara>
506
507       <formalpara>
508         <title><systemitem>--disable-gtk-doc</systemitem> and
509           <systemitem>--enable-gtk-doc</systemitem></title>
510
511         <para>
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+
522           will be installed.
523         </para>
524       </formalpara>
525
526       <formalpara>
527         <title><systemitem>--disable-cups</systemitem> and
528           <systemitem>--enable-cups</systemitem></title>
529
530         <para>
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.
535         </para>
536       </formalpara>
537
538       <formalpara>
539         <title><systemitem>--disable-papi</systemitem> and
540           <systemitem>--enable-papi</systemitem></title>
541
542         <para>
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.
547         </para>
548       </formalpara>
549
550       <formalpara>
551         <title><systemitem>--disable-packagekit</systemitem> and
552            <systemitem>--enable-packagekit</systemitem></title>
553         <para>
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.
559         </para>
560       </formalpara>
561
562       <formalpara>
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>
569
570         <para>
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.
577         </para>
578       </formalpara>
579
580       <formalpara>
581         <title><systemitem>--enable-introspection</systemitem></title>
582
583         <para>
584           Build with or without introspection support.
585           The default is 'auto'.
586         </para>
587       </formalpara>
588
589       <formalpara>
590         <title><systemitem>--enable-gtk2-dependency</systemitem> or
591            <systemitem>--disable-gtk2-dependency</systemitem></title>
592
593         <para>
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.
599         </para>
600       </formalpara>
601     </refsect1>
602
603 </refentry>
604
605 <!-- Local Variables: -->
606 <!-- sgml-parent-document: ("gtk-docs.sgml" "chapter" "refentry")  -->
607 <!-- End: -->