2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
5 <refentry id="glib-building">
7 <refentrytitle>Compiling the GLib package</refentrytitle>
8 <manvolnum>3</manvolnum>
9 <refmiscinfo>GLib Library</refmiscinfo>
13 <refname>Compiling the GLib Package</refname>
14 <refpurpose>How to compile GLib itself</refpurpose>
17 <refsect1 id="building">
18 <title>Building the Library on UNIX</title>
20 On UNIX, GLib uses the standard GNU build system,
21 using <application>autoconf</application> for package
22 configuration and resolving portability issues,
23 <application>automake</application> for building makefiles
24 that comply with the GNU Coding Standards, and
25 <application>libtool</application> for building shared
26 libraries on multiple platforms. The normal sequence for
27 compiling and installing the GLib library is thus:
30 <userinput>./configure</userinput>
31 <userinput>make</userinput>
32 <userinput>make install</userinput>
37 The standard options provided by <application>GNU
38 autoconf</application> may be passed to the
39 <command>configure</command> script. Please see the
40 <application>autoconf</application> documentation or run
41 <command>./configure --help</command> for information about
45 The GTK+ documentation contains
46 <ulink url="../gtk/gtk-building.html">further details</ulink>
47 about the build process and ways to influence it.
50 <refsect1 id="dependencies">
51 <title>Dependencies</title>
53 Before you can compile the GLib library, you need to have
54 various other tools and libraries installed on your system.
55 Beyond a C compiler (which must implement C90, but does not need
56 to implement C99), the two tools needed during the build process
57 (as differentiated from the tools used in when creating GLib
58 mentioned above such as <application>autoconf</application>) are
59 <command>pkg-config</command> and GNU make.
64 <ulink url="http://www.freedesktop.org/software/pkgconfig/">pkg-config</ulink>
65 is a tool for tracking the compilation flags needed for
66 libraries that are used by the GLib library. (For each
67 library, a small <literal>.pc</literal> text file is
68 installed in a standard location that contains the compilation
69 flags needed for that library along with version number
70 information.) The version of <command>pkg-config</command>
71 needed to build GLib is mirrored in the
72 <filename>dependencies</filename> directory
73 on the <ulink url="ftp://ftp.gtk.org/pub/gtk/v2.2/">GTK+ FTP
79 The GLib Makefiles make use of several features specific to
80 <ulink url="http://www.gnu.org/software/make">GNU
81 make</ulink>, and will not build correctly with other
82 versions of <command>make</command>. You will need to
83 install it if you don't already have it on your system. (It
84 may be called <command>gmake</command> rather than
85 <command>make</command>.)
90 A UNIX build of GLib requires that the system implements at
91 least the original 1990 version of POSIX. Beyond this, it
92 depends on a number of other libraries.
97 The <ulink url="http://www.gnu.org/software/libiconv/">GNU
98 libiconv library</ulink> is needed to build GLib if your
99 system doesn't have the <function>iconv()</function>
100 function for doing conversion between character
101 encodings. Most modern systems should have
102 <function>iconv()</function>, however many older systems lack
103 an <function>iconv()</function> implementation. On such systems,
104 you must install the libiconv library. This can be found at:
105 <ulink url="http://www.gnu.org/software/libiconv">http://www.gnu.org/software/libiconv</ulink>.
108 If your system has an <function>iconv()</function> implementation but
109 you want to use libiconv instead, you can pass the
110 --with-libiconv option to configure. This forces
114 Note that if you have libiconv installed in your default include
115 search path (for instance, in <filename>/usr/local/</filename>), but
116 don't enable it, you will get an error while compiling GLib because
117 the <filename>iconv.h</filename> that libiconv installs hides the
121 If you are using the native iconv implementation on Solaris
122 instead of libiconv, you'll need to make sure that you have
123 the converters between locale encodings and UTF-8 installed.
124 At a minimum you'll need the SUNWuiu8 package. You probably
125 should also install the SUNWciu8, SUNWhiu8, SUNWjiu8, and
129 The native iconv on Compaq Tru64 doesn't contain support for
130 UTF-8, so you'll need to use GNU libiconv instead. (When
131 using GNU libiconv for GLib, you'll need to use GNU libiconv
132 for GNU gettext as well.) This probably applies to related
133 operating systems as well.
138 The libintl library from the <ulink
139 url="http://www.gnu.org/software/gettext">GNU gettext
140 package</ulink> is needed if your system doesn't have the
141 <function>gettext()</function> functionality for handling
142 message translation databases.
147 A thread implementation is needed. The thread support in GLib
148 can be based upon POSIX threads or win32 threads.
153 GRegex uses the <ulink url="http://www.pcre.org/">PCRE library</ulink>
154 for regular expression matching. The default is to use the internal
155 version of PCRE that is patched to use GLib for memory management
156 and Unicode handling. If you prefer to use the system-supplied PCRE
157 library you can pass the <option>--with-pcre=system</option> option
158 to, but it is not recommended.
163 The optional extended attribute support in GIO requires the
164 getxattr() family of functions that may be provided by glibc or
165 by the standalone libattr library. To build GLib without extended
166 attribute support, use the <option>--disable-xattr</option>
172 The optional SELinux support in GIO requires libselinux.
173 To build GLib without SELinux support, use the
174 <option>--disable-selinux</option> option.
179 The optional support for DTrace requires the
180 <filename>sys/sdt.h</filename> header, which is provided
181 by SystemTap on Linux. To build GLib without DTrace, use
182 the <option>--disable-dtrace</option> configure option.
187 The optional support for
188 <ulink url="http://sourceware.org/systemtap/">SystemTap</ulink>
189 can be disabled with the <option>--disable-systemtap</option>
196 <refsect1 id="extra-configuration-options">
197 <title>Extra Configuration Options</title>
200 In addition to the normal options, the
201 <command>configure</command> script in the GLib
202 library supports these additional arguments:
206 <title><systemitem>--enable-debug</systemitem></title>
209 Turns on various amounts of debugging support. Setting this to 'no'
210 disables g_assert(), g_return_if_fail(), g_return_val_if_fail() and
211 all cast checks between different object types. Setting it to 'minimum' disables only cast checks. Setting it to 'yes' enables
212 <link linkend="G-DEBUG:CAPS">runtime debugging</link>.
213 The default is 'minimum'.
214 Note that 'no' is fast, but dangerous as it tends to destabilize
215 even mostly bug-free software by changing the effect of many bugs
216 from simple warnings into fatal crashes. Thus
217 <option>--enable-debug=no</option> should <emphasis>not</emphasis>
218 be used for stable releases of GLib.
223 <title><systemitem>--disable-gc-friendly</systemitem> and
224 <systemitem>--enable-gc-friendly</systemitem></title>
227 By default, and with <systemitem>--disable-gc-friendly</systemitem>
228 as well, Glib does not clear the memory for certain objects before
229 they are freed. For example, Glib may decide to recycle GList nodes
230 by putting them in a free list. However, memory profiling and debugging
231 tools like <ulink url="http://www.valgrind.org">Valgrind</ulink> work
232 better if an application does not keep dangling pointers to freed
233 memory (even though these pointers are no longer dereferenced), or
234 invalid pointers inside uninitialized memory.
235 The <systemitem>--enable-gc-friendly</systemitem> option makes Glib
236 clear memory in these situations:
242 When shrinking a GArray, Glib will clear the memory no longer
243 available in the array: shrink an array from 10 bytes to 7, and
244 the last 3 bytes will be cleared. This includes removals of single
245 and multiple elements.
250 When growing a GArray, Glib will clear the new chunk of memory.
251 Grow an array from 7 bytes to 10 bytes, and the last 3 bytes will
257 The above applies to GPtrArray as well.
262 When freeing a node from a GHashTable, Glib will first clear
263 the node, which used to have pointers to the key and the value
269 When destroying or removing a GTree node, Glib will clear the node,
270 which used to have pointers to the node's value, and the left and
277 Since clearing the memory has a cost,
278 <systemitem>--disable-gc-friendly</systemitem> is the default.
283 <title><systemitem>--disable-mem-pools</systemitem> and
284 <systemitem>--enable-mem-pools</systemitem></title>
287 Many small chunks of memory are often allocated via collective pools
288 in GLib and are cached after release to speed up reallocations.
289 For sparse memory systems this behaviour is often inferior, so
290 memory pools can be disabled to avoid excessive caching and force
291 atomic maintenance of chunks through the <function>g_malloc()</function>
292 and <function>g_free()</function> functions. Code currently affected by
297 <structname>GMemChunk</structname>s become basically non-effective
302 <structname>GSignal</structname> disables all caching
303 (potentially very slow)
308 <structname>GType</structname> doesn't honour the
309 <structname>GTypeInfo</structname>
310 <structfield>n_preallocs</structfield> field anymore
315 the <structname>GBSearchArray</structname> flag
316 <literal>G_BSEARCH_ALIGN_POWER2</literal> becomes non-functional
324 <title><systemitem>--with-threads</systemitem></title>
327 Specify a thread implementation to use. Available options are
328 'posix' or 'win32'. Normally, <command>configure</command>
329 should be able to work out the system threads API on its own.
334 <title><systemitem>--disable-regex</systemitem> and
335 <systemitem>--enable-regex</systemitem></title>
338 Do not compile GLib with regular expression support.
339 GLib will be smaller because it will not need the
340 PCRE library. This is however not recommended, as
341 programs may need GRegex.
346 <title><systemitem>--with-pcre</systemitem></title>
349 Specify whether to use the internal or the system-supplied
354 'internal' means that GRegex will be compiled to use
355 the internal PCRE library.
360 'system' means that GRegex will be compiled to use
361 the system-supplied PCRE library.
365 Using the internal PCRE is the preferred solution:
369 System-supplied PCRE has a separated copy of the big tables
370 used for Unicode handling.
375 Some systems have PCRE libraries compiled without some needed
376 features, such as UTF-8 and Unicode support.
381 PCRE uses some global variables for memory management and
382 other features. In the rare case of a program using both
383 GRegex and PCRE (maybe indirectly through a library),
384 this variables could lead to problems when they are modified.
392 <title><systemitem>--disable-included-printf</systemitem> and
393 <systemitem>--enable-included-printf</systemitem></title>
396 By default the <command>configure</command> script will try
397 to auto-detect whether the C library provides a suitable set
398 of printf() functions. In detail, <command>configure</command>
399 checks that the semantics of snprintf() are as specified by C99
400 and that positional parameters as specified in the Single Unix
401 Specification are supported. If this not the case, GLib will
402 include an implementation of the printf() family.
405 These options can be used to explicitly control whether
406 an implementation of the printf() family should be included or not.
411 <title><systemitem>--disable-Bsymbolic</systemitem> and
412 <systemitem>--enable-Bsymbolic</systemitem></title>
415 By default, GLib uses the -Bsymbolic-functions linker
416 flag to avoid intra-library PLT jumps. A side-effect
417 of this is that it is no longer possible to override
418 internal uses of GLib functions with
419 <envar>LD_PRELOAD</envar>. Therefore, it may make
420 sense to turn this feature off in some situations.
421 The <option>--disable-Bsymbolic</option> option allows
427 <title><systemitem>--disable-gtk-doc</systemitem> and
428 <systemitem>--enable-gtk-doc</systemitem></title>
431 By default the <command>configure</command> script will try
432 to auto-detect whether the
433 <application>gtk-doc</application> package is installed.
434 If it is, then it will use it to extract and build the
435 documentation for the GLib library. These options
436 can be used to explicitly control whether
437 <application>gtk-doc</application> should be
438 used or not. If it is not used, the distributed,
439 pre-generated HTML files will be installed instead of
440 building them on your machine.
445 <title><systemitem>--disable-man</systemitem> and
446 <systemitem>--enable-man</systemitem></title>
449 By default the <command>configure</command> script will try
450 to auto-detect whether <application>xsltproc</application>
451 and the necessary Docbook stylesheets are installed.
452 If they are, then it will use them to rebuild the included
453 man pages from the XML sources. These options can be used
454 to explicitly control whether man pages should be rebuilt
455 used or not. The distribution includes pre-generated man
461 <title><systemitem>--disable-xattr</systemitem> and
462 <systemitem>--enable-xattr</systemitem></title>
465 By default the <command>configure</command> script will try
466 to auto-detect whether the getxattr() family of functions
467 is available. If it is, then extended attribute support
468 will be included in GIO. These options can be used to
469 explicitly control whether extended attribute support
470 should be included or not. getxattr() and friends can
471 be provided by glibc or by the standalone libattr library.
476 <title><systemitem>--disable-selinux</systemitem> and
477 <systemitem>--enable-selinux</systemitem></title>
480 By default the <command>configure</command> script will
481 auto-detect if libselinux is available and include
482 SELinux support in GIO if it is. These options can be
483 used to explicitly control whether SELinux support should
489 <title><systemitem>--disable-dtrace</systemitem> and
490 <systemitem>--enable-dtrace</systemitem></title>
493 By default the <command>configure</command> script will
494 detect if DTrace support is available, and use it.
499 <title><systemitem>--disable-systemtap</systemitem> and
500 <systemitem>--enable-systemtap</systemitem></title>
503 This option requires DTrace support. If it is available, then
504 the <command>configure</command> script will also check for
505 the presence of SystemTap.
510 <title><systemitem>--enable-coverage</systemitem> and
511 <systemitem>--disable-coverage</systemitem></title>
514 Enable the generation of coverage reports for the GLib tests.
515 This requires the lcov frontend to gcov from the
516 <ulink url="http://ltp.sourceforge.net">Linux Test Project</ulink>.
517 To generate a coverage report, use the lcov make target. The
518 report is placed in the <filename>glib-lcov</filename> directory.
523 <title><systemitem>--with-runtime-libdir=RELPATH</systemitem></title>
526 Allows specifying a relative path to where to install the runtime
527 libraries (meaning library files used for running, not developing,
528 GLib applications). This can be used in operating system setups where
529 programs using GLib needs to run before e.g. <filename>/usr</filename>
531 For example, if LIBDIR is <filename>/usr/lib</filename> and
532 <filename>../../lib</filename> is passed to
533 <systemitem>--with-runtime-libdir</systemitem> then the
534 runtime libraries are installed into <filename>/lib</filename> rather
535 than <filename>/usr/lib</filename>.
540 <title><systemitem>--with-python</systemitem></title>
543 Allows specifying the Python interpreter to use, either as an absolute path,
544 or as a program name. GLib can be built with Python 2 (at least version 2.5)