1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Compiling the GLib package</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7 <link rel="home" href="index.html" title="GLib Reference Manual">
8 <link rel="up" href="glib.html" title="GLib Overview">
9 <link rel="prev" href="glib.html" title="GLib Overview">
10 <link rel="next" href="glib-cross-compiling.html" title="Cross-compiling the GLib package">
11 <meta name="generator" content="GTK-Doc V1.13 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 <link rel="chapter" href="glib.html" title="GLib Overview">
14 <link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
15 <link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
16 <link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
17 <link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
18 <link rel="chapter" href="tools.html" title="GLib Tools">
19 <link rel="index" href="api-index-full.html" title="Index">
20 <link rel="index" href="api-index-deprecated.html" title="Index of deprecated symbols">
21 <link rel="index" href="api-index-2-2.html" title="Index of new symbols in 2.2">
22 <link rel="index" href="api-index-2-4.html" title="Index of new symbols in 2.4">
23 <link rel="index" href="api-index-2-6.html" title="Index of new symbols in 2.6">
24 <link rel="index" href="api-index-2-8.html" title="Index of new symbols in 2.8">
25 <link rel="index" href="api-index-2-10.html" title="Index of new symbols in 2.10">
26 <link rel="index" href="api-index-2-12.html" title="Index of new symbols in 2.12">
27 <link rel="index" href="api-index-2-14.html" title="Index of new symbols in 2.14">
28 <link rel="index" href="api-index-2-16.html" title="Index of new symbols in 2.16">
29 <link rel="index" href="api-index-2-18.html" title="Index of new symbols in 2.18">
30 <link rel="index" href="api-index-2-20.html" title="Index of new symbols in 2.20">
31 <link rel="index" href="api-index-2-22.html" title="Index of new symbols in 2.22">
32 <link rel="index" href="api-index-2-24.html" title="Index of new symbols in 2.24">
34 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
35 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
36 <td><a accesskey="p" href="glib.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
37 <td><a accesskey="u" href="glib.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
38 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
39 <th width="100%" align="center">GLib Reference Manual</th>
40 <td><a accesskey="n" href="glib-cross-compiling.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
42 <div class="refentry" title="Compiling the GLib package">
43 <a name="glib-building"></a><div class="titlepage"></div>
44 <div class="refnamediv"><table width="100%"><tr>
46 <h2><span class="refentrytitle">Compiling the GLib package</span></h2>
47 <p>Compiling the GLib Package —
48 How to compile GLib itself
51 <td valign="top" align="right"></td>
53 <div class="refsect1" title="Building the Library on UNIX">
54 <a name="building"></a><h2>Building the Library on UNIX</h2>
56 On UNIX, GLib uses the standard GNU build system,
57 using <span class="application">autoconf</span> for package
58 configuration and resolving portability issues,
59 <span class="application">automake</span> for building makefiles
60 that comply with the GNU Coding Standards, and
61 <span class="application">libtool</span> for building shared
62 libraries on multiple platforms. The normal sequence for
63 compiling and installing the GLib library is thus:
66 <div class="literallayout"><p><br>
67 <strong class="userinput"><code>./configure</code></strong><br>
68 <strong class="userinput"><code>make</code></strong><br>
69 <strong class="userinput"><code>make install</code></strong><br>
74 The standard options provided by <span class="application">GNU
75 autoconf</span> may be passed to the
76 <span class="command"><strong>configure</strong></span> script. Please see the
77 <span class="application">autoconf</span> documentation or run
78 <span class="command"><strong>./configure --help</strong></span> for information about
82 The GTK+ documentation contains
83 <a class="ulink" href="http://library.gnome.org/devel/gtk/unstable/gtk-building.html" target="_top">further details</a>
84 about the build process and ways to influence it.
87 <div class="refsect1" title="Dependencies">
88 <a name="dependencies"></a><h2>Dependencies</h2>
90 Before you can compile the GLib library, you need to have
91 various other tools and libraries installed on your
92 system. The two tools needed during the build process (as
93 differentiated from the tools used in when creating GLib
94 mentioned above such as <span class="application">autoconf</span>)
95 are <span class="command"><strong>pkg-config</strong></span> and GNU make.
97 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
98 <li class="listitem"><p>
99 <a class="ulink" href="http://www.freedesktop.org/software/pkgconfig/" target="_top">pkg-config</a>
100 is a tool for tracking the compilation flags needed for
101 libraries that are used by the GLib library. (For each
102 library, a small <code class="literal">.pc</code> text file is
103 installed in a standard location that contains the compilation
104 flags needed for that library along with version number
105 information.) The version of <span class="command"><strong>pkg-config</strong></span>
106 needed to build GLib is mirrored in the
107 <code class="filename">dependencies</code> directory
108 on the <a class="ulink" href="ftp://ftp.gtk.org/pub/gtk/v2.2/" target="_top">GTK+ FTP
111 <li class="listitem"><p>
112 The GTK+ makefiles will mostly work with different versions
113 of <span class="command"><strong>make</strong></span>, however, there tends to be
114 a few incompatibilities, so the GTK+ team recommends
115 installing <a class="ulink" href="http://www.gnu.org/software/make" target="_top">GNU
116 make</a> if you don't already have it on your system
117 and using it. (It may be called <span class="command"><strong>gmake</strong></span>
118 rather than <span class="command"><strong>make</strong></span>.)
122 GLib depends on a number of other libraries.
124 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
125 <li class="listitem">
127 The <a class="ulink" href="http://www.gnu.org/software/libiconv/" target="_top">GNU
128 libiconv library</a> is needed to build GLib if your
129 system doesn't have the <code class="function">iconv()</code>
130 function for doing conversion between character
131 encodings. Most modern systems should have
132 <code class="function">iconv()</code>, however many older systems lack
133 an <code class="function">iconv()</code> implementation. On such systems,
134 you must install the libiconv library. This can be found at:
135 <a class="ulink" href="http://www.gnu.org/software/libiconv" target="_top">http://www.gnu.org/software/libiconv</a>.
138 If your system has an <code class="function">iconv()</code> implementation but
139 you want to use libiconv instead, you can pass the
140 --with-libiconv option to configure. This forces
144 Note that if you have libiconv installed in your default include
145 search path (for instance, in <code class="filename">/usr/local/</code>), but
146 don't enable it, you will get an error while compiling GLib because
147 the <code class="filename">iconv.h</code> that libiconv installs hides the
151 If you are using the native iconv implementation on Solaris
152 instead of libiconv, you'll need to make sure that you have
153 the converters between locale encodings and UTF-8 installed.
154 At a minimum you'll need the SUNWuiu8 package. You probably
155 should also install the SUNWciu8, SUNWhiu8, SUNWjiu8, and
159 The native iconv on Compaq Tru64 doesn't contain support for
160 UTF-8, so you'll need to use GNU libiconv instead. (When
161 using GNU libiconv for GLib, you'll need to use GNU libiconv
162 for GNU gettext as well.) This probably applies to related
163 operating systems as well.
166 <li class="listitem"><p>
167 The libintl library from the <a class="ulink" href="http://www.gnu.org/software/gettext" target="_top">GNU gettext
168 package</a> is needed if your system doesn't have the
169 <code class="function">gettext()</code> functionality for handling
170 message translation databases.
172 <li class="listitem"><p>
173 A thread implementation is needed, unless you want to compile GLib
174 without thread support, which is not recommended. The thread support
175 in GLib can be based upon several native thread implementations,
176 e.g. POSIX threads, DCE threads or Solaris threads.
178 <li class="listitem"><p>
179 GRegex uses the <a class="ulink" href="http://www.pcre.org/" target="_top">PCRE library</a>
180 for regular expression matching. The default is to use the internal
181 version of PCRE that is patched to use GLib for memory management
182 and Unicode handling. If you prefer to use the system-supplied PCRE
183 library you can pass the --with-pcre=system option to configure,
184 but it is not recommended.
186 <li class="listitem"><p>
187 The optional extended attribute support in GIO requires the
188 getxattr() family of functions that may be provided by glibc or
189 by the standalone libattr library. To build GLib without extended
190 attribute support, use the <code class="option">--disable-xattr</code>
193 <li class="listitem"><p>
194 The optional SELinux support in GIO requires libselinux. To build
195 GLib without SELinux support, use the
196 <code class="option">--disable-selinux</code> configure option.
200 <div class="refsect1" title="Extra Configuration Options">
201 <a name="extra-configuration-options"></a><h2>Extra Configuration Options</h2>
203 In addition to the normal options, the
204 <span class="command"><strong>configure</strong></span> script in the GLib
205 library supports these additional arguments:
208 <div class="cmdsynopsis"><p><code class="command">configure</code> [[--enable-debug=[no|minimum|yes]]] [[--disable-gc-friendly] | [--enable-gc-friendly]] [[--disable-mem-pools] | [--enable-mem-pools]] [[--disable-threads] | [--enable-threads]] [[--with-threads=[none|posix|dce|win32]]] [[--disable-regex] | [--enable-regex]] [[--with-pcre=[internal|system]]] [[--disable-included-printf] | [--enable-included-printf]] [[--disable-visibility] | [--enable-visibility]] [[--disable-gtk-doc] | [--enable-gtk-doc]] [[--disable-man] | [--enable-man]] [[--disable-xattr] | [--enable-xattr]] [[--disable-selinux] | [--enable-selinux]] [[--with-runtime-libdir=RELPATH]]</p></div>
211 <p title="--enable-debug"><b><code class="systemitem">--enable-debug</code>. </b>
212 Turns on various amounts of debugging support. Setting this to 'no'
213 disables g_assert(), g_return_if_fail(), g_return_val_if_fail() and
214 all cast checks between different object types. Setting it to 'minimum' disables only cast checks. Setting it to 'yes' enables
216 The default is 'minimum'.
217 Note that 'no' is fast, but dangerous as it tends to destabilize
218 even mostly bug-free software by changing the effect of many bugs
219 from simple warnings into fatal crashes. Thus
220 <code class="option">--enable-debug=no</code> should <span class="emphasis"><em>not</em></span>
221 be used for stable releases of GLib.
223 <p title="--disable-gc-friendly and --enable-gc-friendly"><b><code class="systemitem">--disable-gc-friendly</code> and
224 <code class="systemitem">--enable-gc-friendly</code>. </b>
225 By default, and with <code class="systemitem">--disable-gc-friendly</code>
226 as well, Glib does not clear the memory for certain objects before they
227 are freed. For example, Glib may decide to recycle GList nodes by
228 putting them in a free list. However, memory profiling and debugging tools like <a class="ulink" href="http://www.valgrind.org" target="_top">Valgrind</a> work better if an
229 application does not keep dangling pointers to freed memory (even
230 though these pointers are no longer dereferenced), or invalid pointers inside
231 uninitialized memory. The
232 <code class="systemitem">--enable-gc-friendly</code> option makes Glib clear
233 memory in these situations:
235 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
236 <li class="listitem"><p>
237 When shrinking a GArray, Glib will clear the memory no longer
238 available in the array: shrink an array from 10 bytes to 7, and
239 the last 3 bytes will be cleared. This includes removals of single and multiple elements.
241 <li class="listitem"><p>
243 <li class="listitem"><p>
244 When growing a GArray, Glib will clear the new chunk of memory.
245 Grow an array from 7 bytes to 10 bytes, and the last 3 bytes will be cleared.
247 <li class="listitem"><p>
248 The above applies to GPtrArray as well.
250 <li class="listitem"><p>
251 When freeing a node from a GHashTable, Glib will first clear
252 the node, which used to have pointers to the key and the value
255 <li class="listitem"><p>
256 When destroying or removing a GTree node, Glib will clear the node,
257 which used to have pointers to the node's value, and the left and right subnodes.
261 Since clearing the memory has a cost,
262 <code class="systemitem">--disable-gc-friendly</code> is the default.
264 <p title="--disable-mem-pools and --enable-mem-pools"><b><code class="systemitem">--disable-mem-pools</code> and
265 <code class="systemitem">--enable-mem-pools</code>. </b>
266 Many small chunks of memory are often allocated via collective pools
267 in GLib and are cached after release to speed up reallocations.
268 For sparse memory systems this behaviour is often inferior, so
269 memory pools can be disabled to avoid excessive caching and force
270 atomic maintenance of chunks through the <code class="function">g_malloc()</code>
271 and <code class="function">g_free()</code> functions. Code currently affected by
274 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
275 <li class="listitem"><p>
276 <span class="structname">GList</span>, <span class="structname">GSList</span>,
277 <span class="structname">GNode</span>, <span class="structname">GHash</span>
278 allocations. The functions g_list_push_allocator(),
279 g_list_pop_allocator(), g_slist_push_allocator(),
280 g_slist_pop_allocator(), g_node_push_allocator() and
281 g_node_pop_allocator() are not available
283 <li class="listitem"><p>
284 <span class="structname">GMemChunk</span>s become basically non-effective
286 <li class="listitem"><p>
287 <span class="structname">GSignal</span> disables all caching (potentially
290 <li class="listitem"><p>
291 <span class="structname">GType</span> doesn't honour the
292 <span class="structname">GTypeInfo</span>
293 <em class="structfield"><code>n_preallocs</code></em> field anymore
295 <li class="listitem"><p>
296 the <span class="structname">GBSearchArray</span> flag
297 <code class="literal">G_BSEARCH_ALIGN_POWER2</code> becomes non-functional
300 <p title="--disable-mem-pools and --enable-mem-pools">
302 <p title="--disable-threads and --enable-threads"><b><code class="systemitem">--disable-threads</code> and
303 <code class="systemitem">--enable-threads</code>. </b>
304 Do not compile GLib to be multi thread safe. GLib
305 will be slightly faster then. This is however not
306 recommended, as many programs rely on GLib being
309 <p title="--with-threads"><b><code class="systemitem">--with-threads</code>. </b>
310 Specify a thread implementation to use.
312 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
313 <li class="listitem"><p>
314 'posix' and 'dce' can be used interchangeable
315 to mean the different versions of Posix
316 threads. configure tries to find out, which
319 <li class="listitem"><p>
320 'none' means that GLib will be thread safe,
321 but does not have a default thread
322 implementation. This has to be supplied to
323 <code class="function">g_thread_init()</code> by the programmer.
326 <p title="--with-threads">
329 <p title="--disable-regex and --enable-regex"><b><code class="systemitem">--disable-regex</code> and
330 <code class="systemitem">--enable-regex</code>. </b>
331 Do not compile GLib with regular expression support.
332 GLib will be smaller because it will not need the
333 PCRE library. This is however not recommended, as
334 programs may need GRegex.
336 <p title="--with-pcre"><b><code class="systemitem">--with-pcre</code>. </b>
337 Specify whether to use the internal or the system-supplied
340 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
341 <li class="listitem"><p>
342 'internal' means that GRegex will be compiled to use
343 the internal PCRE library.
345 <li class="listitem"><p>
346 'system' means that GRegex will be compiled to use
347 the system-supplied PCRE library.
350 <p title="--with-pcre">
351 Using the internal PCRE is the preferred solution:
353 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
354 <li class="listitem"><p>
355 System-supplied PCRE has a separated copy of the big tables
356 used for Unicode handling.
358 <li class="listitem"><p>
359 Some systems have PCRE libraries compiled without some needed
360 features, such as UTF-8 and Unicode support.
362 <li class="listitem"><p>
363 PCRE uses some global variables for memory management and
364 other features. In the rare case of a program using both
365 GRegex and PCRE (maybe indirectly through a library),
366 this variables could lead to problems when they are modified.
369 <p title="--with-pcre">
371 <p title="--disable-included-printf and --enable-included-printf"><b><code class="systemitem">--disable-included-printf</code> and
372 <code class="systemitem">--enable-included-printf</code>. </b>
373 By default the <span class="command"><strong>configure</strong></span> script will try
374 to auto-detect whether the C library provides a suitable set
375 of <code class="function">printf()</code> functions. In detail,
376 <span class="command"><strong>configure</strong></span> checks that the semantics of
377 <code class="function">snprintf()</code> are as specified by C99 and
378 that positional parameters as specified in the Single Unix
379 Specification are supported. If this not the case, GLib will
380 include an implementation of the <code class="function">printf()</code>
382 These options can be used to explicitly control whether
383 an implementation fo the <code class="function">printf()</code> family
384 should be included or not.
386 <p title="--disable-visibility and --enable-visibility"><b><code class="systemitem">--disable-visibility</code> and
387 <code class="systemitem">--enable-visibility</code>. </b>
388 By default, GLib uses ELF visibility attributes to optimize
389 PLT table entries if the compiler supports ELF visibility
390 attributes. A side-effect of the way in which this is currently
391 implemented is that any header change forces a full
392 recompilation, and missing includes may go unnoticed.
393 Therefore, it makes sense to turn this feature off while
394 doing GLib development, even if the compiler supports ELF
395 visibility attributes. The <code class="option">--disable-visibility</code>
396 option allows to do that.
398 <p title="--disable-gtk-doc and --enable-gtk-doc"><b><code class="systemitem">--disable-gtk-doc</code> and
399 <code class="systemitem">--enable-gtk-doc</code>. </b>
400 By default the <span class="command"><strong>configure</strong></span> script will try
401 to auto-detect whether the
402 <span class="application">gtk-doc</span> package is installed. If
403 it is, then it will use it to extract and build the
404 documentation for the GLib library. These options
405 can be used to explicitly control whether
406 <span class="application">gtk-doc</span> should be
407 used or not. If it is not used, the distributed,
408 pre-generated HTML files will be installed instead of
409 building them on your machine.
411 <p title="--disable-man and --enable-man"><b><code class="systemitem">--disable-man</code> and
412 <code class="systemitem">--enable-man</code>. </b>
413 By default the <span class="command"><strong>configure</strong></span> script will try
414 to auto-detect whether <span class="application">xsltproc</span>
415 and the necessary Docbook stylesheets are installed. If
416 they are, then it will use them to rebuild the included
417 man pages from the XML sources. These options can be used
418 to explicitly control whether man pages should be rebuilt
419 used or not. The distribution includes pre-generated man
422 <p title="--disable-xattr and --enable-xattr"><b><code class="systemitem">--disable-xattr</code> and
423 <code class="systemitem">--enable-xattr</code>. </b>
424 By default the <span class="command"><strong>configure</strong></span> script will try
425 to auto-detect whether the getxattr() family of functions
426 is available. If it is, then extended attribute support
427 will be included in GIO. These options can be used to
428 explicitly control whether extended attribute support
429 should be included or not. getxattr() and friends can
430 be provided by glibc or by the standalone libattr library.
432 <p title="--disable-selinux and --enable-selinux"><b><code class="systemitem">--disable-selinux</code> and
433 <code class="systemitem">--enable-selinux</code>. </b>
434 By default the <span class="command"><strong>configure</strong></span> script will
435 auto-detect if libselinux is available and include
436 SELinux support in GIO if it is. These options can be
437 used to explicitly control whether SELinux support should
440 <p title="--with-runtime-libdir=RELPATH"><b><code class="systemitem">--with-runtime-libdir=RELPATH</code>. </b>
441 Allows specifying a relative path to where to install the runtime
442 libraries (meaning library files used for running, not developing,
443 GLib applications). This can be used in operating system setups where
444 programs using GLib needs to run before e.g. <code class="filename">/usr</code>
446 For example, if LIBDIR is <code class="filename">/usr/lib</code> and
447 <code class="filename">../../lib</code> is passed to
448 <code class="systemitem">--with-runtime-libdir</code> then the
449 runtime libraries are installed into <code class="filename">/lib</code> rather
450 than <code class="filename">/usr/lib</code>.
456 Generated by GTK-Doc V1.13</div>