1 <refentry id="gtk-building" revision="6 Sept 2001">
3 <refentrytitle>Compiling the GTK+ libraries</refentrytitle>
4 <manvolnum>3</manvolnum>
5 <refmiscinfo>GTK Library</refmiscinfo>
9 <refname>Compiling the GTK+ Libraries</refname>
11 How to compile GTK+ itself
14 <refsect1 id="overview">
15 <title>Building GTK+ on UNIX-like systems</title>
17 This chapter covers building and installing GTK+ on UNIX and
18 UNIX-like systems such as Linux. Compiling GTK+ on Microsoft
19 Windows is different in detail and somewhat more difficult to
20 get going since the necessary tools aren't included with
24 Before we get into the details of how to compile GTK+, we should
25 mention that in many cases, binary packages of GTK+ prebuilt for
26 your operating system will be available, either from your
27 operating system vendor or from independent sources. If such a
28 set of packages is available, installing it will get you
29 programming wih GTK+ much faster than building it yourself. In
30 fact, you may well already have GTK+ installed on your system
34 On UNIX-like systems GTK+ uses the standard GNU build system,
35 using <application>autoconf</application> for package
36 configuration and resolving portability issues,
37 <application>automake</application> for building makefiles that
38 comply with the GNU Coding Standards, and
39 <application>libtool</application> for building shared libraries
40 on multiple platforms.
43 If you are building GTK+ from the distributed source packages,
44 then won't need these tools installed; the necessary pieces
45 of the tools are already included in the source packages. But
46 it's useful to know a bit about how packages that use these
47 tools work. A source package is distributed as a
48 <literal>tar.gz</literal> file which you unpack into a
49 directory full of the source files as follows:
52 tar xvfz gtk+-2.0.0.tar.gz
55 In the toplevel of the directory that is created, there will be
56 a shell script called <filename>configure</filename> which
57 you then run to take the template makefiles called
58 <filename>Makefile.in</filename> in the package and create
59 makefiles customized for your operating system. The <filename>configure</filename>
60 script can be passed various command line arguments to determine how
61 the package is built and installed. The most commonly useful
62 argument is the <systemitem>--prefix</systemitem> argument which
63 determines where the package is installed. To install a package
64 in <filename>/opt/gtk</filename> you would run configure as:
67 ./configure --prefix=/opt/gtk
70 A full list of options can be found by running
71 <filename>configure</filename> with the
72 <systemitem>--help</systemitem> argument. In general, the defaults are
73 right and should be trusted. After you've run
74 <filename>configure</filename>, you then run the
75 <command>make</command> command to build the package and install
83 If you don't have permission to write to the directory you are
84 installing in, you may have to change to root temporarily before
85 running <literal>make install</literal>. Also, if you are
86 installing in a system directory, on some systems (such as
87 Linux), you will need to run <command>ldconfig</command> after
88 <literal>make install</literal> so that the newly installed
89 libraries will be found.
92 Several environment variables are useful to pass to set before
93 running configure. <envar>CPPFLAGS</envar> contains options to
94 pass to the C compiler, and is used to tell the compiler where
95 to look for include files. The <envar>LDFLAGS</envar> variable
96 is used in a similar fashion for the linker. Finally the
97 <envar>PKG_CONFIG_PATH</envar> environment variable contains
98 a search path that <command>pkg-config</command> (see below)
99 uses when looking for for file describing how to compile
100 programs using different libraries. If you were installing GTK+
101 and it's dependencies into <filename>/opt/gtk</filename>, you
102 might want to set these variables as:
105 CPPFLAGS="-I/opt/gtk/include"
106 LDFLAGS="-L/opt/gtk/lib"
107 PKG_CONFIG_PATH="/opt/gtk/lib/pkgconfig"
108 export CPPFLAGS LDFLAGS PKG_CONFIG_PATH
111 You may also need to set the <envar>LD_LIBRARY_PATH</envar>
112 environment variable so the systems dynamic linker can find
113 the newly installed libraries, and the <envar>PATH</envar>
114 environment program so that utility binaries installed by
115 the various libraries will be found.
118 LD_LIBRARY_PATH="/opt/gtk/lib"
119 PATH="/opt/gtk/bin:$PATH"
120 export LD_LIBRARY_PATH PATH
123 <refsect1 id="dependencies">
124 <title>Dependencies</title>
126 Before you can compile the GTK+ widget toolkit, you need to have
127 various other tools and libraries installed on your
128 system. The two tools needed during the build process (as
129 differentiated from the tools used in when creating GTK+
130 mentioned above such as <application>autoconf</application>)
131 are <command>pkg-config</command> and GNU make.
137 url="http://www.freedesktop.org/software/pkgconfig">pkg-config</ulink>
138 is a tool for tracking the compilation flags needed for
139 libraries that are used by the GTK+ libraries. (For each
140 library, a small <literal>.pc</literal> text file is installed
141 in a standard location that contains the compilation flags
142 needed for that library along with version number information.)
143 The version of <command>pkg-config</command> needed to build
144 GTK+ is mirrored in the <filename>dependencies</filename> directory
145 on the <ulink url="ftp://ftp.gtk.org/pub/gtk/v2.6/">GTK+ FTP
151 The GTK+ makefiles will mostly work with different versions
152 of <command>make</command>, however, there tends to be
153 a few incompatibilities, so the GTK+ team recommends
154 installing <ulink url="http://www.gnu.org/software/make">GNU
155 make</ulink> if you don't already have it on your system
156 and using it. (It may be called <command>gmake</command>
157 rather than <command>make</command>.)
162 Three of the libraries that GTK+ depends on are maintained by
163 by the GTK+ team: GLib, Pango, and ATK. Other libraries are
164 maintained separately.
169 The GLib library provides core non-graphical functionality
170 such as high level data types, Unicode manipulation, and
171 an object and type system to C programs. It is available
172 from the <ulink url="ftp://ftp.gtk.org/pub/gtk/v2.6/">GTK+
178 <ulink url="http://www.pango.org">Pango</ulink> is a library
179 for internationalized text handling. It is available from
180 the <ulink url="ftp://ftp.gtk.org/pub/gtk/v2.6/">GTK+ FTP
186 ATK is the Accessibility Toolkit. It provides a set of generic
187 interfaces allowing accessibility technologies such as
188 screen readers to interact with a graphical user interface.
189 It is available from the <ulink
190 url="ftp://ftp.gtk.org/pub/gtk/v2.6/">GTK+ FTP site.</ulink>
195 The <ulink url="http://www.gnu.org/software/libiconv/">GNU
196 libiconv library</ulink> is needed to build GLib if your
197 system doesn't have the <function>iconv()</function>
198 function for doing conversion between character
199 encodings. Most modern systems should have
200 <function>iconv()</function>.
205 The libintl library from the <ulink
206 url="http://www.gnu.org/software/gettext/">GNU gettext
207 package</ulink> is needed if your system doesn't have the
208 <function>gettext()</function> functionality for handling
209 message translation databases.
215 url="ftp://ftp.uu.net/graphics/jpeg/">JPEG</ulink>,
216 <ulink url="http://www.libpng.org">PNG</ulink>, and
217 <ulink url="http://www.libtiff.org">TIFF</ulink> image
218 loading libraries are needed to compile GTK+. You probably
219 already have these libraries installed, but if not, the
220 versions you need are available in the
221 <filename>dependencies</filename> directory on the the
222 <ulink url="ftp://ftp.gtk.org/pub/gtk/v2.6/dependencies/">GTK+
223 FTP site.</ulink>. (Before installing these libraries
224 from source, you should check if your operating system
225 vendor has prebuilt packages of these libraries that you
226 don't have installed.)
231 The libraries from the X window system are needed to build
232 Pango and GTK+. You should already have these installed on
233 your system, but it's possible that you'll need to install
234 the development environment for these libraries that your
235 operating system vendor provides.
240 The <ulink url="http://www.fontconfig.org">fontconfig</ulink>
241 library provides Pango with a standard way of locating
242 fonts and matching them against font names. The
243 <ulink url="http://www.freedesktop.org/wiki/Software/Xft">Xft2</ulink>
244 library, distributed with fontconfig, provides support for
245 scalable and antialiased fonts on X. Pango includes two
246 backends that work on top of fontconfig: an Xft2 backend
247 and a backend that uses fontconfig and the underlying
248 <ulink url="http://www.freetype.org">FreeType</ulink>
249 library directly. Neither backend is mandatory, but the
250 Xft2 backend is the preferred backend for X and the FreeType
251 backend is needed by many applications.
256 <refsect1 id="building">
257 <title>Building and testing GTK+</title>
259 First make sure that you have the necessary external
260 dependencies installed: <command>pkg-config</command>, GNU make,
261 the JPEG, PNG, and TIFF libraries, FreeType, and, if necessary,
262 libiconv and libintl. To get detailed information about building
263 these packages, see the documentation provided with the
265 On a Linux system, it's quite likely you'll have all of these
266 installed already except for <command>pkg-config</command>.
269 Then build and install the GTK+ libraries in the order:
270 GLib, Pango, ATK, then GTK+. For each library, follow the
271 steps of <literal>configure</literal>, <literal>make</literal>,
272 <literal>make install</literal> mentioned above. If you're
273 lucky, this will all go smoothly, and you'll be ready to
274 <link linkend="gtk-compiling">start compiling your own GTK+
275 applications</link>. You can test your GTK+ installation
276 by running the <command>gtk-demo</command> program that
280 If one of the <filename>configure</filename> scripts fails or running
281 <command>make</command> fails, look closely at the error
282 messages printed; these will often provide useful information
283 as to what went wrong. When <filename>configure</filename>
284 fails, extra information, such as errors that a test compilation
285 ran into, is found in the file <filename>config.log</filename>.
286 Looking at the last couple of hundred lines in this file will
287 frequently make clear what went wrong. If all else fails, you
288 can ask for help on the gtk-list mailing list.
289 See <xref linkend="gtk-resources"/> for more information.
292 <refsect1 id="extra-configuration-options">
293 <title>Extra Configuration Options</title>
296 In addition to the normal options, the
297 <command>configure</command> script for the GTK+ library
298 supports a number of additional arguments. (Command line
299 arguments for the other GTK+ libraries are described in
300 the documentation distributed with the those libraries.)
303 <command>configure</command>
306 <arg>--disable-modules</arg>
307 <arg>--enable-modules</arg>
310 <arg>--with-included-loaders==LOADER1,LOADER2,...</arg>
313 <arg>--enable-debug=[no|minimum|yes]</arg>
316 <arg>--disable-visibility</arg>
317 <arg>--enable-visibility</arg>
320 <arg>--disable-shm</arg>
321 <arg>--enable-shm</arg>
324 <arg>--disable-xim</arg>
325 <arg>--enable-xim</arg>
328 <arg>--disable-xim-inst</arg>
329 <arg>--enable-xim-inst</arg>
332 <arg>--disable-xkb</arg>
333 <arg>--enable-xkb</arg>
336 <arg>--disable-gtk-doc</arg>
337 <arg>--enable-gtk-doc</arg>
340 <arg>--with-xinput=[no|yes]</arg>
343 <arg>--with-gdktarget=[x11|linux-fb|win32]</arg>
346 <arg>--disable-shadowfb</arg>
347 <arg>--enable-shadowfb</arg>
353 <title><systemitem>--disable-modules</systemitem> and
354 <systemitem>--enable-modules</systemitem></title>
357 Normally GTK+ will try to build the GdkPixbuf image file
358 format loaders as little shared libraries that are loaded on
359 demand. The <systemitem>--disable-modules</systemitem>
360 argument indicates that they should all be built statically
361 into the GTK+ library instead. This is useful for
362 people who need to produce statically-linked binaries. If
363 neither <systemitem>--disable-modules</systemitem> nor
364 <systemitem>--enable-modules</systemitem> is specified, then
365 the <command>configure</command> script will try to
366 auto-detect whether shared modules work on your system.
371 <title><systemitem>--with-included-loaders</systemitem></title>
374 This option allows you to specify which image loaders you
375 want to include; for example, you might include only the PNG
376 loader to create a smaller GdkPixbuf binary.
381 <title><systemitem>--enable-debug</systemitem></title>
384 Turns on various amounts of debugging support. Setting this to 'no'
385 disables g_assert(), g_return_if_fail(), g_return_val_if_fail() and
386 all cast checks between different object types. Setting it to 'minimum'
387 disables only cast checks. Setting it to 'yes' enables
388 <link linkend="GTK-Debug-Options">runtime debugging</link>.
389 The default is 'minimum'.
390 Note that 'no' is fast, but dangerous as it tends to destabilize
391 even mostly bug-free software by changing the effect of many bugs
392 from simple warnings into fatal crashes. Thus
393 <option>--enable-debug=no</option> should <emphasis>not</emphasis>
394 be used for stable releases of GTK+.
399 <title><systemitem>--disable-visibility</systemitem> and
400 <systemitem>--enable-visibility</systemitem></title>
402 The option <systemitem>--disable-visibility</systemitem>
403 turns off the use of ELF visibility attributes for linking
404 optimizations. This makes sense while changing GTK+ itself,
405 since the way in which GTK+ uses visibility attributes
406 forces a full rebuild of all source files for any header
412 <title><systemitem>--enable-explicit-deps</systemitem> and
413 <systemitem>--disable-explicit-deps</systemitem></title>
415 If <systemitem>--enable-explicit-deps</systemitem> is
416 specified then GTK+ will write the full set of libraries
417 that GTK+ depends upon into its <literal>.pc</literal> files to be used when
418 programs depending on GTK+ are linked. Otherwise, GTK+
419 only will include the GTK+ libraries themselves, and
420 will depend on system library dependency facilities to
421 bring in the other libraries.
422 By default GTK+ will disable explicit dependencies unless
423 it detects that they are needed on the system. (If you
424 specify <systemitem>--enable-static</systemitem> to force
425 building of static libraries, then explicit dependencies
426 will be written since library dependencies don't work
427 for static libraries.) Specifying
428 <systemitem>--enable-explicit-deps</systemitem> or
429 <systemitem>--enable-static</systemitem> can cause
431 problems when libraries that GTK+ depends upon change
432 their versions, and should be avoided if possible.
437 <title><systemitem>--disable-shm</systemitem> and
438 <systemitem>--enable-shm</systemitem></title>
441 These options can be used to control whether GTK+ will use shared
442 memory to communicate with the X server when possible.
443 The default is 'yes'.
448 <title><systemitem>--disable-xim</systemitem> and
449 <systemitem>--enable-xim</systemitem></title>
452 These options can be used to control whether GTK+ will
453 be compiled with support for XIM. (The X Input Method
454 extension, used for Japanese input.) The default is yes.
459 <title><systemitem>--disable-xim-inst</systemitem> and
460 <systemitem>--enable-xim-inst</systemitem></title>
463 These options determine whether GTK+ will use the
464 XIM instantiate callback.
465 The default is 'yes', unless the host system is Solaris,
466 where <function>XRegisterIMInstantiateCallback()</function>
467 seems to cause a segfault.
472 <title><systemitem>--disable-xkb</systemitem> and
473 <systemitem>--enable-xkb</systemitem></title>
476 By default the <command>configure</command> script will try
477 to auto-detect whether the XKB extension is supported by
478 the X libraries GTK+ is linked with.
479 These options can be used to explicitly control whether
480 GTK+ will support the XKB extension.
485 <title><systemitem>--disable-gtk-doc</systemitem> and
486 <systemitem>--enable-gtk-doc</systemitem></title>
489 The <application>gtk-doc</application> package is
490 used to generate the reference documentation included
491 with GTK+. By default support for <application>gtk-doc</application>
492 is disabled because it requires various extra dependencies
493 to be installed. If you have
494 <application>gtk-doc</application> installed and
495 are modifying GTK+, you may want to enable
496 <application>gtk-doc</application> support by passing
497 in <systemitem>--enable-gtk-doc</systemitem>. If not
498 enabled, pre-generated HTML files distributed with GTK+
504 <title><systemitem>--with-xinput</systemitem></title>
506 Controls whether GTK+ is built with support for the XInput
507 extension. The XInput extension provides an interface
508 to extended input devices such as graphics tablets.
509 When this support is compiled in, specially written
510 GTK+ programs can get access to subpixel positions,
511 multiple simultaneous input devices, and extra "axes"
512 provided by the device such as pressure and tilt
513 information. This is only known to work well on XFree86
514 systems, though other systems do have this extension.
518 <title><systemitem>--with-gdktarget</systemitem></title>
521 Toggles between the supported backends for GDK.
522 The default is x11, unless the platform is Windows, in which
523 case the default is win32.
528 <title><systemitem>--disable-shadowfb</systemitem> and
529 <systemitem>--enable-shadowfb</systemitem></title>
532 Toggles shadow framebuffer support for the linux-fb target,
541 <!-- Local Variables: -->
542 <!-- sgml-parent-document: ("gtk-docs.sgml" "chapter" "refentry") -->