~ubuntu-branches/ubuntu/utopic/glib2.0/utopic

« back to all changes in this revision

Viewing changes to docs/reference/glib/building.sgml

Tags: upstream-2.12.12
ImportĀ upstreamĀ versionĀ 2.12.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<refentry id="glib-building" revision="16 Jan 2002">
 
2
<refmeta>
 
3
<refentrytitle>Compiling the GLib package</refentrytitle>
 
4
<manvolnum>3</manvolnum>
 
5
<refmiscinfo>GLib Library</refmiscinfo>
 
6
</refmeta>
 
7
 
 
8
<refnamediv>
 
9
<refname>Compiling the GLib Package</refname>
 
10
<refpurpose>
 
11
How to compile GLib itself
 
12
</refpurpose>
 
13
  </refnamediv>
 
14
 
 
15
    <refsect1 id="building">
 
16
      <title>Building the Library on UNIX</title>
 
17
      <para>
 
18
        On UNIX, GLib uses the standard GNU build system,
 
19
        using <application>autoconf</application> for package
 
20
        configuration and resolving portability issues,
 
21
        <application>automake</application> for building makefiles
 
22
        that comply with the GNU Coding Standards, and
 
23
        <application>libtool</application> for building shared
 
24
        libraries on multiple platforms.  The normal sequence for
 
25
        compiling and installing the GLib library is thus:
 
26
 
 
27
        <literallayout>
 
28
          <userinput>./configure</userinput>
 
29
          <userinput>make</userinput>
 
30
          <userinput>make install</userinput>
 
31
        </literallayout>
 
32
      </para>
 
33
 
 
34
      <para>
 
35
        The standard options provided by <application>GNU
 
36
        autoconf</application> may be passed to the
 
37
        <command>configure</command> script.  Please see the
 
38
        <application>autoconf</application> documentation or run
 
39
        <command>./configure --help</command> for information about
 
40
        the standard options.
 
41
      </para>
 
42
      <para>
 
43
        The GTK+ documentation contains 
 
44
        <ulink url="../gtk/gtk-building.html">further details</ulink> 
 
45
        about the build process and ways to influence it. 
 
46
      </para>
 
47
    </refsect1>
 
48
    <refsect1 id="dependencies">
 
49
      <title>Dependencies</title>
 
50
      <para>
 
51
        Before you can compile the GLib library, you need to have
 
52
        various other tools and libraries installed on your
 
53
        system. The two tools needed during the build process (as
 
54
        differentiated from the tools used in when creating GLib
 
55
        mentioned above such as <application>autoconf</application>)
 
56
        are <command>pkg-config</command> and GNU make.
 
57
      </para>
 
58
      <itemizedlist>
 
59
        <listitem>
 
60
          <para>
 
61
            <ulink
 
62
            url="http://www.freedesktop.org/software/pkgconfig/">pkg-config</ulink>
 
63
            is a tool for tracking the compilation flags needed for
 
64
            libraries that are used by the GLib library. (For each
 
65
            library, a small <literal>.pc</literal> text file is 
 
66
            installed in a standard location that contains the compilation 
 
67
            flags needed for that library along with version number 
 
68
            information.)  The version of <command>pkg-config</command> 
 
69
            needed to build GLib is mirrored in the 
 
70
            <filename>dependencies</filename> directory
 
71
            on the <ulink url="ftp://ftp.gtk.org/pub/gtk/v2.2/">GTK+ FTP
 
72
            site.</ulink>
 
73
          </para>
 
74
        </listitem>
 
75
        <listitem>
 
76
          <para>
 
77
            The GTK+ makefiles will mostly work with different versions
 
78
            of <command>make</command>, however, there tends to be
 
79
            a few incompatibilities, so the GTK+ team recommends
 
80
            installing <ulink url="http://www.gnu.org/software/make">GNU
 
81
            make</ulink> if you don't already have it on your system
 
82
            and using it. (It may be called <command>gmake</command>
 
83
            rather than <command>make</command>.)
 
84
          </para>
 
85
        </listitem>
 
86
      </itemizedlist>
 
87
      <para>
 
88
        GLib depends on a number of other libraries.
 
89
      </para>
 
90
      <itemizedlist>
 
91
        <listitem>
 
92
          <para>
 
93
          The <ulink url="http://www.gnu.org/software/libiconv/">GNU
 
94
          libiconv library</ulink> is needed to build GLib if your
 
95
          system doesn't have the <function>iconv()</function>
 
96
          function for doing conversion between character
 
97
          encodings. Most modern systems should have
 
98
          <function>iconv()</function>, however many older systems lack 
 
99
          an <function>iconv()</function> implementation. On such systems, 
 
100
          you must install the libiconv library. This can be found at:
 
101
          <ulink url="http://www.gnu.org/software/libiconv">http://www.gnu.org/software/libiconv</ulink>.         
 
102
        </para>
 
103
        <para>
 
104
          If your system has an <function>iconv()</function> implementation but
 
105
          you want to use libiconv instead, you can pass the
 
106
          --with-libiconv option to configure. This forces
 
107
          libiconv to be used.  
 
108
        </para>
 
109
        <para>
 
110
          Note that if you have libiconv installed in your default include
 
111
          search path (for instance, in <filename>/usr/local/</filename>), but
 
112
          don't enable it, you will get an error while compiling GLib because
 
113
          the <filename>iconv.h</filename> that libiconv installs hides the
 
114
          system iconv. 
 
115
        </para>
 
116
        <para>
 
117
          If you are using the native iconv implementation on Solaris
 
118
          instead of libiconv, you'll need to make sure that you have 
 
119
          the converters between locale encodings and UTF-8 installed.
 
120
          At a minimum you'll need the SUNWuiu8 package. You probably
 
121
          should also install the SUNWciu8, SUNWhiu8, SUNWjiu8, and
 
122
          SUNWkiu8 packages.
 
123
        </para>
 
124
        <para>
 
125
          The native iconv on Compaq Tru64 doesn't contain support for
 
126
          UTF-8, so you'll need to use GNU libiconv instead. (When
 
127
          using GNU libiconv for GLib, you'll need to use GNU libiconv
 
128
          for GNU gettext as well.) This probably applies to related
 
129
          operating systems as well.
 
130
        </para>
 
131
      </listitem>
 
132
      <listitem>
 
133
        <para>
 
134
          The libintl library from the <ulink
 
135
          url="http://www.gtk.org/software/gettext">GNU gettext
 
136
          package</ulink> is needed if your system doesn't have the
 
137
          <function>gettext()</function> functionality for handling
 
138
          message translation databases.
 
139
        </para>
 
140
      </listitem>
 
141
      <listitem>
 
142
        <para>
 
143
          A thread implementation is needed, unless you want to compile GLib
 
144
          without thread support, which is not recommended. The thread support
 
145
          in GLib can be based upon several native thread implementations,
 
146
          e.g. POSIX threads, DCE threads or Solaris threads. 
 
147
        </para>
 
148
      </listitem>
 
149
    </itemizedlist>
 
150
 
 
151
    </refsect1>
 
152
    <refsect1 id="extra-configuration-options">
 
153
      <title>Extra Configuration Options</title>
 
154
 
 
155
      <para>
 
156
        In addition to the normal options, the
 
157
        <command>configure</command> script in the GLib
 
158
        library supports these additional arguments:
 
159
 
 
160
        <cmdsynopsis>
 
161
          <command>configure</command>
 
162
          <group>
 
163
            <arg>--enable-debug=[no|minimum|yes]</arg>
 
164
          </group>
 
165
          <group>
 
166
            <arg>--disable-gc-friendly</arg>
 
167
            <arg>--enable-gc-friendly</arg>
 
168
          </group>
 
169
          <group>
 
170
            <arg>--disable-mem-pools</arg>
 
171
            <arg>--enable-mem-pools</arg>
 
172
          </group>
 
173
          <group>
 
174
            <arg>--disable-threads</arg>
 
175
            <arg>--enable-threads</arg>
 
176
          </group>
 
177
          <group>
 
178
            <arg>--with-threads=[none|posix|dce|win32]</arg>
 
179
          </group>
 
180
          <group>
 
181
             <arg>--disable-included-printf</arg>
 
182
             <arg>--enable-included-printf</arg>
 
183
          </group>
 
184
          <group>
 
185
             <arg>--disable-visibility</arg>
 
186
             <arg>--enable-visibility</arg>
 
187
          </group>
 
188
          <group>
 
189
            <arg>--disable-gtk-doc</arg>
 
190
            <arg>--enable-gtk-doc</arg>
 
191
          </group>
 
192
          <group>
 
193
            <arg>--disable-man</arg>
 
194
            <arg>--enable-man</arg>
 
195
          </group>
 
196
        </cmdsynopsis>
 
197
      </para>
 
198
 
 
199
      <formalpara>
 
200
        <title><systemitem>--enable-debug</systemitem></title>
 
201
 
 
202
        <para>
 
203
         Turns on various amounts of debugging support. Setting this to 'no'
 
204
         disables g_assert(), g_return_if_fail(), g_return_val_if_fail() and
 
205
         all cast checks between different object types. Setting it to 'minimum'         disables only cast checks. Setting it to 'yes' enables
 
206
         <link linkend="GLIB-Debug-Options">runtime debugging</link>.
 
207
         The default is 'minimum'.
 
208
         Note that 'no' is fast, but dangerous as it tends to destabilize
 
209
         even mostly bug-free software by changing the effect of many bugs
 
210
         from simple warnings into fatal crashes. Thus
 
211
         <option>--enable-debug=no</option> should <emphasis>not</emphasis>
 
212
         be used for stable releases of GLib.
 
213
        </para>
 
214
      </formalpara>
 
215
 
 
216
      <formalpara>
 
217
        <title><systemitem>--disable-gc-friendly</systemitem> and
 
218
          <systemitem>--enable-gc-friendly</systemitem></title>
 
219
 
 
220
        <para>
 
221
          By default, and with <systemitem>--disable-gc-friendly</systemitem>
 
222
          as well, Glib does not clear the memory for certain objects before they
 
223
          are freed.  For example, Glib may decide to recycle GList nodes by
 
224
          putting them in a free list.  However, memory profiling and debugging tools like <ulink
 
225
          url="http://www.valgrind.org">Valgrind</ulink> work better if an
 
226
          application does not keep dangling pointers to freed memory (even
 
227
          though these pointers are no longer dereferenced), or invalid pointers inside
 
228
          uninitialized memory.   The
 
229
          <systemitem>--enable-gc-friendly</systemitem> option makes Glib clear
 
230
          memory in these situations:
 
231
        </para>
 
232
      </formalpara>
 
233
 
 
234
      <itemizedlist>
 
235
        <listitem>
 
236
          <para>
 
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.
 
240
          </para>
 
241
        </listitem>
 
242
        <listitem>
 
243
          <para>
 
244
          </para>
 
245
        </listitem>
 
246
        <listitem>
 
247
          <para>
 
248
            When growing a GArray, Glib will clear the new chunk of memory.  
 
249
            Grow an array from 7 bytes to 10 bytes, and the last 3 bytes will be cleared.
 
250
          </para>
 
251
        </listitem>
 
252
        <listitem>
 
253
          <para>
 
254
            The above applies to GPtrArray as well.
 
255
          </para>
 
256
        </listitem>
 
257
        <listitem>
 
258
          <para>
 
259
            When freeing a node from a GHashTable, Glib will first clear
 
260
            the node, which used to have pointers to the key and the value 
 
261
            stored at that node.
 
262
          </para>
 
263
        </listitem>
 
264
        <listitem>
 
265
          <para>
 
266
            When destroying or removing a GTree node, Glib will clear the node,
 
267
            which used to have pointers to the node's value, and the left and right subnodes.
 
268
          </para>
 
269
        </listitem>
 
270
      </itemizedlist>
 
271
 
 
272
      <para>
 
273
        Since clearing the memory has a cost,
 
274
        <systemitem>--disable-gc-friendly</systemitem> is the default.
 
275
      </para>
 
276
 
 
277
      <formalpara>
 
278
        <title><systemitem>--disable-mem-pools</systemitem> and
 
279
          <systemitem>--enable-mem-pools</systemitem></title>
 
280
 
 
281
      <para>
 
282
        Many small chunks of memory are often allocated via collective pools
 
283
        in GLib and are cached after release to speed up reallocations.
 
284
        For sparse memory systems this behaviour is often inferior, so
 
285
        memory pools can be disabled to avoid excessive caching and force
 
286
        atomic maintenance of chunks through the <function>g_malloc()</function>
 
287
        and <function>g_free()</function> functions. Code currently affected by 
 
288
        this:
 
289
        <itemizedlist>
 
290
        <listitem>
 
291
        <para>
 
292
         <structname>GList</structname>, <structname>GSList</structname>,
 
293
         <structname>GNode</structname>, <structname>GHash</structname> 
 
294
         allocations. The functions g_list_push_allocator(), 
 
295
         g_list_pop_allocator(), g_slist_push_allocator(), 
 
296
         g_slist_pop_allocator(), g_node_push_allocator() and 
 
297
         g_node_pop_allocator() are not available
 
298
        </para>
 
299
        </listitem>
 
300
        <listitem>
 
301
        <para>
 
302
        <structname>GMemChunk</structname>s become basically non-effective
 
303
        </para>
 
304
        </listitem>
 
305
        <listitem>
 
306
        <para>
 
307
         <structname>GSignal</structname> disables all caching (potentially 
 
308
         very slow)
 
309
        </para>
 
310
        </listitem>
 
311
        <listitem>
 
312
        <para>
 
313
         <structname>GType</structname> doesn't honour the 
 
314
         <structname>GTypeInfo</structname> 
 
315
         <structfield>n_preallocs</structfield> field anymore
 
316
        </para>
 
317
        </listitem>
 
318
        <listitem>
 
319
        <para>
 
320
         the <structname>GBSearchArray</structname> flag 
 
321
         <literal>G_BSEARCH_ALIGN_POWER2</literal> becomes non-functional
 
322
        </para>
 
323
        </listitem>
 
324
        </itemizedlist>
 
325
      </para>
 
326
      </formalpara>
 
327
 
 
328
      <formalpara>
 
329
        <title><systemitem>--disable-threads</systemitem> and
 
330
          <systemitem>--enable-threads</systemitem></title>
 
331
 
 
332
        <para>
 
333
           Do not compile GLib to be multi thread safe. GLib
 
334
           will be slightly faster then. This is however not
 
335
           recommended, as many programs rely on GLib being
 
336
           multi thread safe.
 
337
        </para>
 
338
      </formalpara>
 
339
 
 
340
      <formalpara>
 
341
        <title><systemitem>--with-threads</systemitem></title>
 
342
 
 
343
        <para>
 
344
          Specify a thread implementation to use.
 
345
          <itemizedlist>
 
346
              <listitem><para>
 
347
                'posix' and 'dce' can be used interchangeable
 
348
                to mean the different versions of Posix
 
349
                threads. configure tries to find out, which
 
350
                one is installed.
 
351
              </para></listitem>
 
352
 
 
353
              <listitem><para>
 
354
                'none' means that GLib will be thread safe,
 
355
                but does not have a default thread
 
356
                implementation. This has to be supplied to
 
357
                <function>g_thread_init()</function> by the programmer.
 
358
              </para></listitem>
 
359
        </itemizedlist>
 
360
 
 
361
        </para>
 
362
      </formalpara>
 
363
 
 
364
      <formalpara>
 
365
         <title><systemitem>--disable-included-printf</systemitem> and
 
366
           <systemitem>--enable-included-printf</systemitem></title>
 
367
 
 
368
        <para>
 
369
          By default the <command>configure</command> script will try
 
370
          to auto-detect whether the C library provides a suitable set
 
371
          of <function>printf()</function> functions. In detail, 
 
372
          <command>configure</command> checks that the semantics of
 
373
          <function>snprintf()</function> are as specified by C99 and
 
374
          that positional parameters as specified in the Single Unix
 
375
          Specification are supported. If this not the case, GLib will
 
376
          include an implementation of the <function>printf()</function> 
 
377
          family.
 
378
          These options can be used to explicitly control whether
 
379
          an implementation fo the <function>printf()</function> family
 
380
          should be included or not.
 
381
        </para>
 
382
      </formalpara>
 
383
 
 
384
      <formalpara>
 
385
         <title><systemitem>--disable-visibility</systemitem> and
 
386
           <systemitem>--enable-visibility</systemitem></title>
 
387
 
 
388
        <para>
 
389
          By default, GLib uses ELF visibility attributes to optimize
 
390
          PLT table entries if the compiler supports ELF visibility
 
391
          attributes. A side-effect of the way in which this is currently
 
392
          implemented is that any  header change forces a full 
 
393
          recompilation, and missing includes may go unnoticed. 
 
394
          Therefore, it makes sense to turn this feature off while
 
395
          doing GLib development, even if the compiler supports ELF
 
396
          visibility attributes. The <option>--disable-visibility</option> 
 
397
          option allows to do that.
 
398
        </para>
 
399
      </formalpara>
 
400
 
 
401
      <formalpara>
 
402
        <title><systemitem>--disable-gtk-doc</systemitem> and
 
403
          <systemitem>--enable-gtk-doc</systemitem></title>
 
404
 
 
405
        <para>
 
406
          By default the <command>configure</command> script will try
 
407
          to auto-detect whether the
 
408
          <application>gtk-doc</application> package is installed.  If
 
409
          it is, then it will use it to extract and build the
 
410
          documentation for the GLib library.  These options
 
411
          can be used to explicitly control whether
 
412
          <application>gtk-doc</application> should be
 
413
          used or not.  If it is not used, the distributed,
 
414
          pre-generated HTML files will be installed instead of
 
415
          building them on your machine.
 
416
        </para>
 
417
      </formalpara>
 
418
 
 
419
      <formalpara>
 
420
        <title><systemitem>--disable-man</systemitem> and
 
421
          <systemitem>--enable-man</systemitem></title>
 
422
 
 
423
        <para>
 
424
          By default the <command>configure</command> script will try
 
425
          to auto-detect whether <application>xsltproc</application> 
 
426
          and the necessary Docbook stylesheets are installed.  If
 
427
          they are, then it will use them to rebuild the included
 
428
          man pages from the XML sources.  These options can be used 
 
429
          to explicitly control whether man pages should be rebuilt
 
430
          used or not. The distribution includes pre-generated man 
 
431
          pages.
 
432
        </para>
 
433
      </formalpara>
 
434
 
 
435
   </refsect1>
 
436
 
 
437
</refentry>