Blame docs/reference/glib/html/glib-building.html

Packit ae235b
Packit ae235b
<html>
Packit ae235b
<head>
Packit ae235b
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Packit ae235b
<title>Compiling the GLib package: GLib Reference Manual</title>
Packit ae235b
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
Packit ae235b
<link rel="home" href="index.html" title="GLib Reference Manual">
Packit ae235b
<link rel="up" href="glib.html" title="GLib Overview">
Packit ae235b
<link rel="prev" href="glib.html" title="GLib Overview">
Packit ae235b
<link rel="next" href="glib-cross-compiling.html" title="Cross-compiling the GLib package">
Packit ae235b
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
Packit ae235b
<link rel="stylesheet" href="style.css" type="text/css">
Packit ae235b
</head>
Packit ae235b
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit ae235b
Packit ae235b
Packit ae235b
Home
Packit ae235b
Up
Packit ae235b
Prev
Packit ae235b
Next
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Compiling the GLib package

Packit ae235b

Compiling the GLib Package — How to compile GLib itself

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Building the Library on UNIX

Packit ae235b

Packit ae235b
      On UNIX, GLib uses the standard GNU build system,
Packit ae235b
      using autoconf for package
Packit ae235b
      configuration and resolving portability issues,
Packit ae235b
      automake for building makefiles
Packit ae235b
      that comply with the GNU Coding Standards, and
Packit ae235b
      libtool for building shared
Packit ae235b
      libraries on multiple platforms.  The normal sequence for
Packit ae235b
      compiling and installing the GLib library is thus:
Packit ae235b
Packit ae235b
      

Packit ae235b


Packit ae235b
        ./configure
Packit ae235b
        make
Packit ae235b
        make install
Packit ae235b
      

Packit ae235b

Packit ae235b
    

Packit ae235b

Packit ae235b
      The standard options provided by GNU
Packit ae235b
      autoconf may be passed to the
Packit ae235b
      configure script.  Please see the
Packit ae235b
      autoconf documentation or run
Packit ae235b
      ./configure --help for information about
Packit ae235b
      the standard options.
Packit ae235b
    

Packit ae235b

Packit ae235b
      GLib is compiled with
Packit ae235b
      strict aliasing
Packit ae235b
      disabled. It is strongly recommended that this is not re-enabled by
Packit ae235b
      overriding the compiler flags, as GLib has not been tested with strict
Packit ae235b
      aliasing and cannot be guaranteed to work.
Packit ae235b
    

Packit ae235b

Packit ae235b
      The GTK+ documentation contains
Packit ae235b
      further details
Packit ae235b
      about the build process and ways to influence it.
Packit ae235b
    

Packit ae235b
Packit ae235b
Packit ae235b

Dependencies

Packit ae235b

Packit ae235b
      Before you can compile the GLib library, you need to have
Packit ae235b
      various other tools and libraries installed on your system.
Packit ae235b
      If you are building from a release archive, you will need
Packit ae235b
      a compliant C toolchain,
Packit ae235b
      GNU Make, and pkg-config;
Packit ae235b
      if you are building directly from a Git repository clone
Packit ae235b
      of GLib, you will also need the GNU Autotools mentioned
Packit ae235b
      above.
Packit ae235b
    

Packit ae235b
    Packit ae235b
  • Packit ae235b
              pkg-config
    Packit ae235b
              is a tool for tracking the compilation flags needed for
    Packit ae235b
              libraries that are used by the GLib library. (For each
    Packit ae235b
              library, a small .pc text file is
    Packit ae235b
              installed in a standard location that contains the compilation
    Packit ae235b
              flags needed for that library along with version number
    Packit ae235b
              information).
    Packit ae235b
            

    Packit ae235b
  • Packit ae235b
              The GLib Makefiles make use of several features specific to
    Packit ae235b
              GNU
    Packit ae235b
              make, and will not build correctly with other
    Packit ae235b
              versions of make. You will need to
    Packit ae235b
              install it if you don't already have it on your system. (It
    Packit ae235b
              may be called gmake rather than
    Packit ae235b
              make.)
    Packit ae235b
            

    Packit ae235b
    Packit ae235b

    Packit ae235b
          A UNIX build of GLib requires that the system implements at
    Packit ae235b
          least the original 1990 version of POSIX. Beyond this, it
    Packit ae235b
          depends on a number of other libraries.
    Packit ae235b
        

    Packit ae235b
      Packit ae235b
    • Packit ae235b

      Packit ae235b
                The GNU
      Packit ae235b
                libiconv library is needed to build GLib if your
      Packit ae235b
                system doesn't have the iconv()
      Packit ae235b
                function for doing conversion between character
      Packit ae235b
                encodings. Most modern systems should have
      Packit ae235b
                iconv(), however many older systems lack
      Packit ae235b
                an iconv() implementation. On such systems,
      Packit ae235b
                you must install the libiconv library. This can be found at:
      Packit ae235b
                http://www.gnu.org/software/libiconv.
      Packit ae235b
              

      Packit ae235b

      Packit ae235b
                If your system has an iconv() implementation but
      Packit ae235b
                you want to use libiconv instead, you can pass the
      Packit ae235b
                --with-libiconv option to configure. This forces
      Packit ae235b
                libiconv to be used.
      Packit ae235b
              

      Packit ae235b

      Packit ae235b
                Note that if you have libiconv installed in your default include
      Packit ae235b
                search path (for instance, in /usr/local/), but
      Packit ae235b
                don't enable it, you will get an error while compiling GLib because
      Packit ae235b
                the iconv.h that libiconv installs hides the
      Packit ae235b
                system iconv.
      Packit ae235b
              

      Packit ae235b

      Packit ae235b
                If you are using the native iconv implementation on Solaris
      Packit ae235b
                instead of libiconv, you'll need to make sure that you have
      Packit ae235b
                the converters between locale encodings and UTF-8 installed.
      Packit ae235b
                At a minimum you'll need the SUNWuiu8 package. You probably
      Packit ae235b
                should also install the SUNWciu8, SUNWhiu8, SUNWjiu8, and
      Packit ae235b
                SUNWkiu8 packages.
      Packit ae235b
              

      Packit ae235b

      Packit ae235b
                The native iconv on Compaq Tru64 doesn't contain support for
      Packit ae235b
                UTF-8, so you'll need to use GNU libiconv instead. (When
      Packit ae235b
                using GNU libiconv for GLib, you'll need to use GNU libiconv
      Packit ae235b
                for GNU gettext as well.) This probably applies to related
      Packit ae235b
                operating systems as well.
      Packit ae235b
              

      Packit ae235b
      Packit ae235b
    • Packit ae235b
                The libintl library from the GNU gettext
      Packit ae235b
                package is needed if your system doesn't have the
      Packit ae235b
                gettext() functionality for handling
      Packit ae235b
                message translation databases.
      Packit ae235b
              

      Packit ae235b
    • Packit ae235b
                A thread implementation is needed. The thread support in GLib
      Packit ae235b
                can be based upon POSIX threads or win32 threads.
      Packit ae235b
              

      Packit ae235b
    • Packit ae235b
                GRegex uses the PCRE library
      Packit ae235b
                for regular expression matching. The default is to use the system
      Packit ae235b
                version of PCRE, to reduce the chances of security fixes going out
      Packit ae235b
                of sync. GLib additionally provides an internal copy of PCRE in case
      Packit ae235b
                the system version is too old, or does not support UTF-8; the internal
      Packit ae235b
                copy is patched to use GLib for memory management and to share the
      Packit ae235b
                same Unicode tables.
      Packit ae235b
              

      Packit ae235b
    • Packit ae235b
                The optional extended attribute support in GIO requires the
      Packit ae235b
                getxattr() family of functions that may be
      Packit ae235b
                provided by the C library or by the standalone libattr library. To
      Packit ae235b
                build GLib without extended attribute support, use the
      Packit ae235b
                --disable-xattr option.
      Packit ae235b
              

      Packit ae235b
    • Packit ae235b
                The optional SELinux support in GIO requires libselinux.
      Packit ae235b
                To build GLib without SELinux support, use the
      Packit ae235b
                --disable-selinux option.
      Packit ae235b
              

      Packit ae235b
    • Packit ae235b
                The optional support for DTrace requires the
      Packit ae235b
                sys/sdt.h header, which is provided
      Packit ae235b
                by SystemTap on Linux. To build GLib without DTrace, use
      Packit ae235b
                the --disable-dtrace configure option.
      Packit ae235b
              

      Packit ae235b
    • Packit ae235b
                The optional support for
      Packit ae235b
                SystemTap
      Packit ae235b
                can be disabled with the --disable-systemtap
      Packit ae235b
                configure option. Additionally, you can control the location
      Packit ae235b
                where GLib installs the SystemTap probes, using the
      Packit ae235b
                --with-tapset-install-dir=DIR configure option.
      Packit ae235b
              

      Packit ae235b
      Packit ae235b
      Packit ae235b
      Packit ae235b

      Extra Configuration Options

      Packit ae235b

      Packit ae235b
            In addition to the normal options, the
      Packit ae235b
            configure script in the GLib
      Packit ae235b
            library supports these additional arguments:
      Packit ae235b
          

      Packit ae235b

      --enable-debug

      Packit ae235b
              Turns on various amounts of debugging support. Setting this to 'no'
      Packit ae235b
              disables g_assert(), g_return_if_fail(),
      Packit ae235b
              g_return_val_if_fail() and all cast checks
      Packit ae235b
              between different object types. Setting it to 'minimum' disables
      Packit ae235b
              only cast checks. Setting it to 'yes' enables runtime debugging.
      Packit ae235b
              The default is 'minimum' for stable releases, and 'yes' for development
      Packit ae235b
              snapshots. Note that 'no' is fast, but dangerous as it tends to destabilize
      Packit ae235b
              even mostly bug-free software by changing the effect of many bugs
      Packit ae235b
              from simple warnings into fatal crashes. Thus
      Packit ae235b
              --enable-debug=no should not
      Packit ae235b
              be used for stable releases of GLib.
      Packit ae235b
            

      Packit ae235b

      --disable-gc-friendly and

      Packit ae235b
              --enable-gc-friendly
      Packit ae235b
              By default, and with --disable-gc-friendly
      Packit ae235b
              as well, GLib does not clear the memory for certain objects before
      Packit ae235b
              they are freed. For example, GLib may decide to recycle GList nodes
      Packit ae235b
              by putting them in a free list. However, memory profiling and debugging
      Packit ae235b
              tools like Valgrind work
      Packit ae235b
              better if an application does not keep dangling pointers to freed
      Packit ae235b
              memory (even though these pointers are no longer dereferenced), or
      Packit ae235b
              invalid pointers inside uninitialized memory.
      Packit ae235b
              The --enable-gc-friendly option makes GLib
      Packit ae235b
              clear memory in these situations:
      Packit ae235b
            

      Packit ae235b
        Packit ae235b
      • Packit ae235b
                    When shrinking a GArray, GLib will clear the memory no longer
        Packit ae235b
                    available in the array: shrink an array from 10 bytes to 7, and
        Packit ae235b
                    the last 3 bytes will be cleared. This includes removals of single
        Packit ae235b
                    and multiple elements.
        Packit ae235b
                  

        Packit ae235b
      • Packit ae235b
                    When growing a GArray, GLib will clear the new chunk of memory.
        Packit ae235b
                    Grow an array from 7 bytes to 10 bytes, and the last 3 bytes will
        Packit ae235b
                    be cleared.
        Packit ae235b
                  

        Packit ae235b
      • Packit ae235b
                    The above applies to GPtrArray as well.
        Packit ae235b
                  

        Packit ae235b
      • Packit ae235b
                    When freeing a node from a GHashTable, GLib will first clear
        Packit ae235b
                    the node, which used to have pointers to the key and the value
        Packit ae235b
                    stored at that node.
        Packit ae235b
                  

        Packit ae235b
      • Packit ae235b
                    When destroying or removing a GTree node, GLib will clear the node,
        Packit ae235b
                    which used to have pointers to the node's value, and the left and
        Packit ae235b
                    right subnodes.
        Packit ae235b
                  

        Packit ae235b
        Packit ae235b

        Packit ae235b
                Since clearing the memory has a cost,
        Packit ae235b
                --disable-gc-friendly is the default.
        Packit ae235b
              

        Packit ae235b

        --disable-mem-pools and

        Packit ae235b
                --enable-mem-pools
        Packit ae235b
                Many small chunks of memory are often allocated via collective pools
        Packit ae235b
                in GLib and are cached after release to speed up reallocations.
        Packit ae235b
                For sparse memory systems this behaviour is often inferior, so
        Packit ae235b
                memory pools can be disabled to avoid excessive caching and force
        Packit ae235b
                atomic maintenance of chunks through the g_malloc()
        Packit ae235b
                and g_free() functions. Code currently affected by
        Packit ae235b
                this:
        Packit ae235b
                

        Packit ae235b
          Packit ae235b
        • Packit ae235b
                        GMemChunks become basically non-effective
          Packit ae235b
                      

          Packit ae235b
        • Packit ae235b
                        GSignal disables all caching
          Packit ae235b
                        (potentially very slow)
          Packit ae235b
                      

          Packit ae235b
        • Packit ae235b
                        GType doesn't honour the
          Packit ae235b
                        GTypeInfo
          Packit ae235b
                        n_preallocs field anymore
          Packit ae235b
                      

          Packit ae235b
        • Packit ae235b
                        the GBSearchArray flag
          Packit ae235b
                        G_BSEARCH_ALIGN_POWER2 becomes non-functional
          Packit ae235b
                      

          Packit ae235b
          Packit ae235b

          Packit ae235b
                

          Packit ae235b

          --with-threads

          Packit ae235b
                  Specify a thread implementation to use. Available options are
          Packit ae235b
                  'posix' or 'win32'. Normally, configure
          Packit ae235b
                  should be able to work out the system threads API on its own.
          Packit ae235b
                

          Packit ae235b

          --with-pcre

          Packit ae235b
                  Specify whether to use the internal or the system-supplied
          Packit ae235b
                  PCRE library.
          Packit ae235b
                  

          Packit ae235b
            Packit ae235b
          • Packit ae235b
                          'internal' means that GRegex will be compiled to use
            Packit ae235b
                          the internal PCRE library.
            Packit ae235b
                        

            Packit ae235b
          • Packit ae235b
                          'system' means that GRegex will be compiled to use
            Packit ae235b
                          the system-supplied PCRE library; this is the default
            Packit ae235b
                          setting.
            Packit ae235b
                        

            Packit ae235b
            Packit ae235b

            Packit ae235b
                    Using the internal PCRE is the preferred solution if:
            Packit ae235b
                    

            Packit ae235b
              Packit ae235b
            • Packit ae235b
                            your system has strict resource constraints; the system-supplied
              Packit ae235b
                            PCRE has a separated copy of the tables used for Unicode
              Packit ae235b
                            handling, whereas the internal copy shares the Unicode tables
              Packit ae235b
                            used by GLib.
              Packit ae235b
                          

              Packit ae235b
            • Packit ae235b
                            your system has PCRE built without some needed features,
              Packit ae235b
                            such as UTF-8 and Unicode support.
              Packit ae235b
                          

              Packit ae235b
            • Packit ae235b
                            you are planning to use both GRegex and PCRE API at the same
              Packit ae235b
                            time, either directly or indirectly through a dependency; PCRE
              Packit ae235b
                            uses some global variables for memory management and
              Packit ae235b
                            other features, and if both GLib and PCRE try to access them
              Packit ae235b
                            at the same time, this could lead to undefined behavior.
              Packit ae235b
                          

              Packit ae235b
              Packit ae235b

              Packit ae235b
                    

              Packit ae235b

              --disable-included-printf and

              Packit ae235b
                      --enable-included-printf
              Packit ae235b
                      By default the configure script will try
              Packit ae235b
                      to auto-detect whether the C library provides a suitable set
              Packit ae235b
                      of printf() functions. In detail,
              Packit ae235b
                      configure checks that the semantics of
              Packit ae235b
                      snprintf() are as specified by C99
              Packit ae235b
                      and that positional parameters as specified in the Single Unix
              Packit ae235b
                      Specification are supported. If this not the case, GLib will
              Packit ae235b
                      include an implementation of the printf()
              Packit ae235b
                      family.
              Packit ae235b
                    
              Packit ae235b
                      These options can be used to explicitly control whether
              Packit ae235b
                      an implementation of the printf() family
              Packit ae235b
                      should be included or not.
              Packit ae235b
                    

              Packit ae235b

              --disable-Bsymbolic and

              Packit ae235b
                      --enable-Bsymbolic
              Packit ae235b
                      By default, GLib uses the -Bsymbolic-functions
              Packit ae235b
                      linker flag to avoid intra-library PLT jumps. A side-effect
              Packit ae235b
                      of this is that it is no longer possible to override
              Packit ae235b
                      internal uses of GLib functions with
              Packit ae235b
                      LD_PRELOAD. Therefore, it may make
              Packit ae235b
                      sense to turn this feature off in some situations.
              Packit ae235b
                      The --disable-Bsymbolic option allows
              Packit ae235b
                      to do that.
              Packit ae235b
                    

              Packit ae235b

              --disable-gtk-doc and

              Packit ae235b
                      --enable-gtk-doc
              Packit ae235b
                      By default the configure script will try
              Packit ae235b
                      to auto-detect whether the
              Packit ae235b
                      gtk-doc package is installed.
              Packit ae235b
                      If it is, then it will use it to extract and build the
              Packit ae235b
                      documentation for the GLib library. These options
              Packit ae235b
                      can be used to explicitly control whether
              Packit ae235b
                      gtk-doc should be
              Packit ae235b
                      used or not. If it is not used, the distributed,
              Packit ae235b
                      pre-generated HTML files will be installed instead of
              Packit ae235b
                      building them on your machine.
              Packit ae235b
                    

              Packit ae235b

              --disable-man and

              Packit ae235b
                      --enable-man
              Packit ae235b
                      By default the configure script will try
              Packit ae235b
                      to auto-detect whether xsltproc
              Packit ae235b
                      and the necessary Docbook stylesheets are installed.
              Packit ae235b
                      If they are, then it will use them to rebuild the included
              Packit ae235b
                      man pages from the XML sources. These options can be used
              Packit ae235b
                      to explicitly control whether man pages should be rebuilt
              Packit ae235b
                      used or not. The distribution includes pre-generated man
              Packit ae235b
                      pages.
              Packit ae235b
                    

              Packit ae235b

              --disable-xattr and

              Packit ae235b
                      --enable-xattr
              Packit ae235b
                      By default the configure script will try
              Packit ae235b
                      to auto-detect whether the getxattr()
              Packit ae235b
                      family of functions is available. If it is, then extended
              Packit ae235b
                      attribute support will be included in GIO. These options can
              Packit ae235b
                      be used to explicitly control whether extended attribute
              Packit ae235b
                      support should be included or not. getxattr()
              Packit ae235b
                      and friends can be provided by glibc or by the standalone
              Packit ae235b
                      libattr library.
              Packit ae235b
                    

              Packit ae235b

              --disable-selinux and

              Packit ae235b
                      --enable-selinux
              Packit ae235b
                      By default the configure script will
              Packit ae235b
                      auto-detect if libselinux is available and include
              Packit ae235b
                      SELinux support in GIO if it is. These options can be
              Packit ae235b
                      used to explicitly control whether SELinux support should
              Packit ae235b
                      be included.
              Packit ae235b
                    

              Packit ae235b

              --disable-dtrace and

              Packit ae235b
                      --enable-dtrace
              Packit ae235b
                      By default the configure script will
              Packit ae235b
                      detect if DTrace support is available, and use it.
              Packit ae235b
                    

              Packit ae235b

              --disable-systemtap and

              Packit ae235b
                      --enable-systemtap
              Packit ae235b
                      This option requires DTrace support. If it is available, then
              Packit ae235b
                      the configure script will also check for
              Packit ae235b
                      the presence of SystemTap.
              Packit ae235b
                    

              Packit ae235b

              --enable-coverage and

              Packit ae235b
                      --disable-coverage
              Packit ae235b
                      Enable the generation of coverage reports for the GLib tests.
              Packit ae235b
                      This requires the lcov frontend to gcov from the
              Packit ae235b
                      Linux Test Project.
              Packit ae235b
                      To generate a coverage report, use the lcov make target. The
              Packit ae235b
                      report is placed in the glib-lcov directory.
              Packit ae235b
                    

              Packit ae235b

              --with-runtime-libdir=RELPATH

              Packit ae235b
                      Allows specifying a relative path to where to install the runtime
              Packit ae235b
                      libraries (meaning library files used for running, not developing,
              Packit ae235b
                      GLib applications). This can be used in operating system setups where
              Packit ae235b
                      programs using GLib needs to run before e.g. /usr
              Packit ae235b
                      is mounted.
              Packit ae235b
                      For example, if LIBDIR is /usr/lib and
              Packit ae235b
                      ../../lib is passed to
              Packit ae235b
                      --with-runtime-libdir then the
              Packit ae235b
                      runtime libraries are installed into /lib rather
              Packit ae235b
                      than /usr/lib.
              Packit ae235b
                    

              Packit ae235b

              --with-python=PATH

              Packit ae235b
                      Allows specifying the Python interpreter to use, either as an absolute path,
              Packit ae235b
                      or as a program name. GLib can be built with Python 2 (at least version 2.7)
              Packit ae235b
                      or, preferably, with Python 3.
              Packit ae235b
                    

              Packit ae235b
              Packit ae235b
              Packit ae235b
              Packit ae235b

              Generated by GTK-Doc V1.27
              Packit ae235b
              </body>
              Packit ae235b
              </html>