Building the Library on UNIX
On UNIX, GLib uses the standard GNU build system,
using autoconf for package
configuration and resolving portability issues,
automake for building makefiles
that comply with the GNU Coding Standards, and
libtool for building shared
libraries on multiple platforms. The normal sequence for
compiling and installing the GLib library is thus:
./configure
make
make install
The standard options provided by GNU
autoconf may be passed to the
configure script. Please see the
autoconf documentation or run
./configure --help for information about
the standard options.
The GTK+ documentation contains
further details
about the build process and ways to influence it.
Extra Configuration Options
In addition to the normal options, the
configure script in the GLib
library supports these additional arguments:
configure
[[--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]]
--enable-debug
.
Turns on various amounts of debugging support. Setting this to 'no'
disables g_assert(), g_return_if_fail(), g_return_val_if_fail() and
all cast checks between different object types. Setting it to 'minimum' disables only cast checks. Setting it to 'yes' enables
runtime debugging.
The default is 'minimum'.
Note that 'no' is fast, but dangerous as it tends to destabilize
even mostly bug-free software by changing the effect of many bugs
from simple warnings into fatal crashes. Thus
--enable-debug=no
should not
be used for stable releases of GLib.
--disable-gc-friendly
and
--enable-gc-friendly
.
By default, and with --disable-gc-friendly
as well, Glib does not clear the memory for certain objects before they
are freed. For example, Glib may decide to recycle GList nodes by
putting them in a free list. However, memory profiling and debugging tools like Valgrind work better if an
application does not keep dangling pointers to freed memory (even
though these pointers are no longer dereferenced), or invalid pointers inside
uninitialized memory. The
--enable-gc-friendly
option makes Glib clear
memory in these situations:
When shrinking a GArray, Glib will clear the memory no longer
available in the array: shrink an array from 10 bytes to 7, and
the last 3 bytes will be cleared. This includes removals of single and multiple elements.
When growing a GArray, Glib will clear the new chunk of memory.
Grow an array from 7 bytes to 10 bytes, and the last 3 bytes will be cleared.
The above applies to GPtrArray as well.
When freeing a node from a GHashTable, Glib will first clear
the node, which used to have pointers to the key and the value
stored at that node.
When destroying or removing a GTree node, Glib will clear the node,
which used to have pointers to the node's value, and the left and right subnodes.
Since clearing the memory has a cost,
--disable-gc-friendly
is the default.
--disable-mem-pools
and
--enable-mem-pools
.
Many small chunks of memory are often allocated via collective pools
in GLib and are cached after release to speed up reallocations.
For sparse memory systems this behaviour is often inferior, so
memory pools can be disabled to avoid excessive caching and force
atomic maintenance of chunks through the g_malloc()
and g_free()
functions. Code currently affected by
this:
GList, GSList,
GNode, GHash
allocations. The functions g_list_push_allocator(),
g_list_pop_allocator(), g_slist_push_allocator(),
g_slist_pop_allocator(), g_node_push_allocator() and
g_node_pop_allocator() are not available
GMemChunks become basically non-effective
GSignal disables all caching (potentially
very slow)
GType doesn't honour the
GTypeInfo
n_preallocs
field anymore
the GBSearchArray flag
G_BSEARCH_ALIGN_POWER2
becomes non-functional
--disable-threads
and
--enable-threads
.
Do not compile GLib to be multi thread safe. GLib
will be slightly faster then. This is however not
recommended, as many programs rely on GLib being
multi thread safe.
--with-threads
.
Specify a thread implementation to use.
'posix' and 'dce' can be used interchangeable
to mean the different versions of Posix
threads. configure tries to find out, which
one is installed.
'none' means that GLib will be thread safe,
but does not have a default thread
implementation. This has to be supplied to
g_thread_init()
by the programmer.
--disable-regex
and
--enable-regex
.
Do not compile GLib with regular expression support.
GLib will be smaller because it will not need the
PCRE library. This is however not recommended, as
programs may need GRegex.
--with-pcre
.
Specify whether to use the internal or the system-supplied
PCRE library.
Using the internal PCRE is the preferred solution:
System-supplied PCRE has a separated copy of the big tables
used for Unicode handling.
Some systems have PCRE libraries compiled without some needed
features, such as UTF-8 and Unicode support.
PCRE uses some global variables for memory management and
other features. In the rare case of a program using both
GRegex and PCRE (maybe indirectly through a library),
this variables could lead to problems when they are modified.
--disable-included-printf
and
--enable-included-printf
.
By default the configure script will try
to auto-detect whether the C library provides a suitable set
of printf()
functions. In detail,
configure checks that the semantics of
snprintf()
are as specified by C99 and
that positional parameters as specified in the Single Unix
Specification are supported. If this not the case, GLib will
include an implementation of the printf()
family.
These options can be used to explicitly control whether
an implementation fo the printf()
family
should be included or not.
--disable-visibility
and
--enable-visibility
.
By default, GLib uses ELF visibility attributes to optimize
PLT table entries if the compiler supports ELF visibility
attributes. A side-effect of the way in which this is currently
implemented is that any header change forces a full
recompilation, and missing includes may go unnoticed.
Therefore, it makes sense to turn this feature off while
doing GLib development, even if the compiler supports ELF
visibility attributes. The --disable-visibility
option allows to do that.
--disable-gtk-doc
and
--enable-gtk-doc
.
By default the configure script will try
to auto-detect whether the
gtk-doc package is installed. If
it is, then it will use it to extract and build the
documentation for the GLib library. These options
can be used to explicitly control whether
gtk-doc should be
used or not. If it is not used, the distributed,
pre-generated HTML files will be installed instead of
building them on your machine.
--disable-man
and
--enable-man
.
By default the configure script will try
to auto-detect whether xsltproc
and the necessary Docbook stylesheets are installed. If
they are, then it will use them to rebuild the included
man pages from the XML sources. These options can be used
to explicitly control whether man pages should be rebuilt
used or not. The distribution includes pre-generated man
pages.
--disable-xattr
and
--enable-xattr
.
By default the configure script will try
to auto-detect whether the getxattr() family of functions
is available. If it is, then extended attribute support
will be included in GIO. These options can be used to
explicitly control whether extended attribute support
should be included or not. getxattr() and friends can
be provided by glibc or by the standalone libattr library.
--disable-selinux
and
--enable-selinux
.
By default the configure script will
auto-detect if libselinux is available and include
SELinux support in GIO if it is. These options can be
used to explicitly control whether SELinxu support should
be included.