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> 11How 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.gnu.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 <listitem> 150 <para> 151 GRegex uses the <ulink url="http://www.pcre.org/">PCRE library</ulink> 152 for regular expression matching. The default is to use the internal 153 version of PCRE that is patched to use GLib for memory management 154 and Unicode handling. If you prefer to use the system-supplied PCRE 155 library you can pass the --with-pcre=system option to configure, 156 but it is not recommended. 157 </para> 158 </listitem> 159 <listitem> 160 <para> 161 The optional extended attribute support in GIO requires the 162 getxattr() family of functions that may be provided by glibc or 163 by the standalone libattr library. To build GLib without extended 164 attribute support, use the <option>--disable-xattr</option> 165 configure option. 166 </para> 167 </listitem> 168 <listitem> 169 <para> 170 The optional SELinux support in GIO requires libselinux. To build 171 GLib without SELinux support, use the 172 <option>--disable-selinux</option> configure option. 173 </para> 174 </listitem> 175 </itemizedlist> 176 177 </refsect1> 178 <refsect1 id="extra-configuration-options"> 179 <title>Extra Configuration Options</title> 180 181 <para> 182 In addition to the normal options, the 183 <command>configure</command> script in the GLib 184 library supports these additional arguments: 185 186 <cmdsynopsis> 187 <command>configure</command> 188 <group> 189 <arg>--enable-debug=[no|minimum|yes]</arg> 190 </group> 191 <group> 192 <arg>--disable-gc-friendly</arg> 193 <arg>--enable-gc-friendly</arg> 194 </group> 195 <group> 196 <arg>--disable-mem-pools</arg> 197 <arg>--enable-mem-pools</arg> 198 </group> 199 <group> 200 <arg>--disable-threads</arg> 201 <arg>--enable-threads</arg> 202 </group> 203 <group> 204 <arg>--with-threads=[none|posix|dce|win32]</arg> 205 </group> 206 <group> 207 <arg>--disable-regex</arg> 208 <arg>--enable-regex</arg> 209 </group> 210 <group> 211 <arg>--with-pcre=[internal|system]</arg> 212 </group> 213 <group> 214 <arg>--disable-included-printf</arg> 215 <arg>--enable-included-printf</arg> 216 </group> 217 <group> 218 <arg>--disable-visibility</arg> 219 <arg>--enable-visibility</arg> 220 </group> 221 <group> 222 <arg>--disable-gtk-doc</arg> 223 <arg>--enable-gtk-doc</arg> 224 </group> 225 <group> 226 <arg>--disable-man</arg> 227 <arg>--enable-man</arg> 228 </group> 229 <group> 230 <arg>--disable-xattr</arg> 231 <arg>--enable-xattr</arg> 232 </group> 233 <group> 234 <arg>--disable-selinux</arg> 235 <arg>--enable-selinux</arg> 236 </group> 237 </cmdsynopsis> 238 </para> 239 240 <formalpara> 241 <title><systemitem>--enable-debug</systemitem></title> 242 243 <para> 244 Turns on various amounts of debugging support. Setting this to 'no' 245 disables g_assert(), g_return_if_fail(), g_return_val_if_fail() and 246 all cast checks between different object types. Setting it to 'minimum' disables only cast checks. Setting it to 'yes' enables 247 <link linkend="GLIB-Debug-Options">runtime debugging</link>. 248 The default is 'minimum'. 249 Note that 'no' is fast, but dangerous as it tends to destabilize 250 even mostly bug-free software by changing the effect of many bugs 251 from simple warnings into fatal crashes. Thus 252 <option>--enable-debug=no</option> should <emphasis>not</emphasis> 253 be used for stable releases of GLib. 254 </para> 255 </formalpara> 256 257 <formalpara> 258 <title><systemitem>--disable-gc-friendly</systemitem> and 259 <systemitem>--enable-gc-friendly</systemitem></title> 260 261 <para> 262 By default, and with <systemitem>--disable-gc-friendly</systemitem> 263 as well, Glib does not clear the memory for certain objects before they 264 are freed. For example, Glib may decide to recycle GList nodes by 265 putting them in a free list. However, memory profiling and debugging tools like <ulink 266 url="http://www.valgrind.org">Valgrind</ulink> work better if an 267 application does not keep dangling pointers to freed memory (even 268 though these pointers are no longer dereferenced), or invalid pointers inside 269 uninitialized memory. The 270 <systemitem>--enable-gc-friendly</systemitem> option makes Glib clear 271 memory in these situations: 272 </para> 273 </formalpara> 274 275 <itemizedlist> 276 <listitem> 277 <para> 278 When shrinking a GArray, Glib will clear the memory no longer 279 available in the array: shrink an array from 10 bytes to 7, and 280 the last 3 bytes will be cleared. This includes removals of single and multiple elements. 281 </para> 282 </listitem> 283 <listitem> 284 <para> 285 </para> 286 </listitem> 287 <listitem> 288 <para> 289 When growing a GArray, Glib will clear the new chunk of memory. 290 Grow an array from 7 bytes to 10 bytes, and the last 3 bytes will be cleared. 291 </para> 292 </listitem> 293 <listitem> 294 <para> 295 The above applies to GPtrArray as well. 296 </para> 297 </listitem> 298 <listitem> 299 <para> 300 When freeing a node from a GHashTable, Glib will first clear 301 the node, which used to have pointers to the key and the value 302 stored at that node. 303 </para> 304 </listitem> 305 <listitem> 306 <para> 307 When destroying or removing a GTree node, Glib will clear the node, 308 which used to have pointers to the node's value, and the left and right subnodes. 309 </para> 310 </listitem> 311 </itemizedlist> 312 313 <para> 314 Since clearing the memory has a cost, 315 <systemitem>--disable-gc-friendly</systemitem> is the default. 316 </para> 317 318 <formalpara> 319 <title><systemitem>--disable-mem-pools</systemitem> and 320 <systemitem>--enable-mem-pools</systemitem></title> 321 322 <para> 323 Many small chunks of memory are often allocated via collective pools 324 in GLib and are cached after release to speed up reallocations. 325 For sparse memory systems this behaviour is often inferior, so 326 memory pools can be disabled to avoid excessive caching and force 327 atomic maintenance of chunks through the <function>g_malloc()</function> 328 and <function>g_free()</function> functions. Code currently affected by 329 this: 330 <itemizedlist> 331 <listitem> 332 <para> 333 <structname>GList</structname>, <structname>GSList</structname>, 334 <structname>GNode</structname>, <structname>GHash</structname> 335 allocations. The functions g_list_push_allocator(), 336 g_list_pop_allocator(), g_slist_push_allocator(), 337 g_slist_pop_allocator(), g_node_push_allocator() and 338 g_node_pop_allocator() are not available 339 </para> 340 </listitem> 341 <listitem> 342 <para> 343 <structname>GMemChunk</structname>s become basically non-effective 344 </para> 345 </listitem> 346 <listitem> 347 <para> 348 <structname>GSignal</structname> disables all caching (potentially 349 very slow) 350 </para> 351 </listitem> 352 <listitem> 353 <para> 354 <structname>GType</structname> doesn't honour the 355 <structname>GTypeInfo</structname> 356 <structfield>n_preallocs</structfield> field anymore 357 </para> 358 </listitem> 359 <listitem> 360 <para> 361 the <structname>GBSearchArray</structname> flag 362 <literal>G_BSEARCH_ALIGN_POWER2</literal> becomes non-functional 363 </para> 364 </listitem> 365 </itemizedlist> 366 </para> 367 </formalpara> 368 369 <formalpara> 370 <title><systemitem>--disable-threads</systemitem> and 371 <systemitem>--enable-threads</systemitem></title> 372 373 <para> 374 Do not compile GLib to be multi thread safe. GLib 375 will be slightly faster then. This is however not 376 recommended, as many programs rely on GLib being 377 multi thread safe. 378 </para> 379 </formalpara> 380 381 <formalpara> 382 <title><systemitem>--with-threads</systemitem></title> 383 384 <para> 385 Specify a thread implementation to use. 386 <itemizedlist> 387 <listitem><para> 388 'posix' and 'dce' can be used interchangeable 389 to mean the different versions of Posix 390 threads. configure tries to find out, which 391 one is installed. 392 </para></listitem> 393 394 <listitem><para> 395 'none' means that GLib will be thread safe, 396 but does not have a default thread 397 implementation. This has to be supplied to 398 <function>g_thread_init()</function> by the programmer. 399 </para></listitem> 400 </itemizedlist> 401 402 </para> 403 </formalpara> 404 405 <formalpara> 406 <title><systemitem>--disable-regex</systemitem> and 407 <systemitem>--enable-regex</systemitem></title> 408 409 <para> 410 Do not compile GLib with regular expression support. 411 GLib will be smaller because it will not need the 412 PCRE library. This is however not recommended, as 413 programs may need GRegex. 414 </para> 415 </formalpara> 416 417 <formalpara> 418 <title><systemitem>--with-pcre</systemitem></title> 419 420 <para> 421 Specify whether to use the internal or the system-supplied 422 PCRE library. 423 <itemizedlist> 424 <listitem><para> 425 'internal' means that GRegex will be compiled to use 426 the internal PCRE library. 427 </para></listitem> 428 429 <listitem><para> 430 'system' means that GRegex will be compiled to use 431 the system-supplied PCRE library. 432 </para></listitem> 433 </itemizedlist> 434 Using the internal PCRE is the preferred solution: 435 <itemizedlist> 436 <listitem> 437 <para> 438 System-supplied PCRE has a separated copy of the big tables 439 used for Unicode handling. 440 </para> 441 </listitem> 442 <listitem> 443 <para> 444 Some systems have PCRE libraries compiled without some needed 445 features, such as UTF-8 and Unicode support. 446 </para> 447 </listitem> 448 <listitem> 449 <para> 450 PCRE uses some global variables for memory management and 451 other features. In the rare case of a program using both 452 GRegex and PCRE (maybe indirectly through a library), 453 this variables could lead to problems when they are modified. 454 </para> 455 </listitem> 456 </itemizedlist> 457 </para> 458 </formalpara> 459 460 <formalpara> 461 <title><systemitem>--disable-included-printf</systemitem> and 462 <systemitem>--enable-included-printf</systemitem></title> 463 464 <para> 465 By default the <command>configure</command> script will try 466 to auto-detect whether the C library provides a suitable set 467 of <function>printf()</function> functions. In detail, 468 <command>configure</command> checks that the semantics of 469 <function>snprintf()</function> are as specified by C99 and 470 that positional parameters as specified in the Single Unix 471 Specification are supported. If this not the case, GLib will 472 include an implementation of the <function>printf()</function> 473 family. 474 These options can be used to explicitly control whether 475 an implementation fo the <function>printf()</function> family 476 should be included or not. 477 </para> 478 </formalpara> 479 480 <formalpara> 481 <title><systemitem>--disable-visibility</systemitem> and 482 <systemitem>--enable-visibility</systemitem></title> 483 484 <para> 485 By default, GLib uses ELF visibility attributes to optimize 486 PLT table entries if the compiler supports ELF visibility 487 attributes. A side-effect of the way in which this is currently 488 implemented is that any header change forces a full 489 recompilation, and missing includes may go unnoticed. 490 Therefore, it makes sense to turn this feature off while 491 doing GLib development, even if the compiler supports ELF 492 visibility attributes. The <option>--disable-visibility</option> 493 option allows to do that. 494 </para> 495 </formalpara> 496 497 <formalpara> 498 <title><systemitem>--disable-gtk-doc</systemitem> and 499 <systemitem>--enable-gtk-doc</systemitem></title> 500 501 <para> 502 By default the <command>configure</command> script will try 503 to auto-detect whether the 504 <application>gtk-doc</application> package is installed. If 505 it is, then it will use it to extract and build the 506 documentation for the GLib library. These options 507 can be used to explicitly control whether 508 <application>gtk-doc</application> should be 509 used or not. If it is not used, the distributed, 510 pre-generated HTML files will be installed instead of 511 building them on your machine. 512 </para> 513 </formalpara> 514 515 <formalpara> 516 <title><systemitem>--disable-man</systemitem> and 517 <systemitem>--enable-man</systemitem></title> 518 519 <para> 520 By default the <command>configure</command> script will try 521 to auto-detect whether <application>xsltproc</application> 522 and the necessary Docbook stylesheets are installed. If 523 they are, then it will use them to rebuild the included 524 man pages from the XML sources. These options can be used 525 to explicitly control whether man pages should be rebuilt 526 used or not. The distribution includes pre-generated man 527 pages. 528 </para> 529 </formalpara> 530 531 <formalpara> 532 <title><systemitem>--disable-xattr</systemitem> and 533 <systemitem>--enable-xattr</systemitem></title> 534 535 <para> 536 By default the <command>configure</command> script will try 537 to auto-detect whether the getxattr() family of functions 538 is available. If it is, then extended attribute support 539 will be included in GIO. These options can be used to 540 explicitly control whether extended attribute support 541 should be included or not. getxattr() and friends can 542 be provided by glibc or by the standalone libattr library. 543 </para> 544 </formalpara> 545 546 <formalpara> 547 <title><systemitem>--disable-selinux</systemitem> and 548 <systemitem>--enable-selinux</systemitem></title> 549 550 <para> 551 By default the <command>configure</command> script will 552 auto-detect if libselinux is available and include 553 SELinux support in GIO if it is. These options can be 554 used to explicitly control whether SELinxu support should 555 be included. 556 </para> 557 </formalpara> 558 </refsect1> 559 560</refentry> 561