Generated by GPT-5-mini| GLib | |
|---|---|
![]() ScotXW · CC BY-SA 4.0 · source | |
| Name | GLib |
| Developer | GNOME Project |
| Released | 1999 |
| Programming language | C (programming language) |
| Operating system | Unix-like; Microsoft Windows |
| License | GNU Lesser General Public License |
GLib GLib is a low-level utility library that provides data structures, portability wrappers, event loops, and common utilities for applications and libraries. It underpins many projects in the GNOME Project ecosystem and is widely used in Linux distributions, BSD variants, and ports to Microsoft Windows. The library focuses on performance, portability, and a stable API/ABI suitable for long-lived desktop, server, and embedded software maintained by contributors from organizations such as Red Hat, Collabora, and independent developers.
GLib supplies foundational building blocks used by higher-level frameworks like GTK+ and GStreamer and by applications such as GNOME Shell, Evolution (software), and NetworkManager. It offers core facilities including generic containers, string utilities, file and I/O abstractions, memory allocation helpers, and a main event loop used by event-driven systems like D-Bus clients and media players such as Totem (media player). The library is written in C (programming language) with an emphasis on cross-platform support across Linux, FreeBSD, OpenBSD, NetBSD, Haiku (operating system), and Windows NT-family systems.
GLib originated in the late 1990s as part of the early GNOME effort to create a consistent runtime for graphical applications. Early maintainers included contributors associated with projects like Red Hat and Ximian, who also worked on Mono (software) and Evolution (software). Over successive releases, GLib evolved to incorporate modern practices drawn from influences such as the C Standard Library, POSIX, and portability work from The GNU Project. Major milestones include introduction of the GObject system inspired by object models used in Objective-C and CORBA, incorporation of thread support aligned with POSIX threads, and adoption of a stable GNU Lesser General Public License licensing model to encourage use by both proprietary and open-source projects.
The architecture centers on a modular set of components meant to be independent yet interoperable. Core parts include: - The GObject type and object system that provides runtime type information, properties, and signals used by libraries like GTK+ and GStreamer. - Generic container implementations (single/double linked lists, hash tables, arrays) comparable to data models in C++ Standard Library and GLibc utilities. - The main event loop (GMainLoop/GMainContext) that interconnects with event sources such as file descriptors, timeouts, and child-watch handlers similar to event models in libevent and libuv. - Portable wrappers for I/O, file handling, and thread primitives that abstract differences between POSIX and Windows NT APIs. - Utility modules for string handling, Unicode support, and internationalization aligning with standards from Unicode Consortium and integration points with ICU in some environments.
GLib exposes a C API designed for predictable binary compatibility across releases. Key features include: - GObject, enabling object-oriented patterns in C with introspection-compatible metadata used by tools like GObject Introspection and language bindings. - GIO, an I/O and streaming abstraction layer providing interfaces for asynchronous file operations, sockets, and network services leveraged by GVfs and NetworkManager. - GLib's collection APIs (GList, GHashTable, GArray) that simplify container management in applications such as Evolution (software) and Geary (email client). - Robust Unicode and string utilities with integration possibilities to Pango for text layout and HarfBuzz for shaping. - Utilities for process spawning and child process monitoring comparable to facilities in systemd-adjacent tooling. The API contract emphasizes reference counting, explicit memory ownership, and error reporting via GError structures to facilitate interoperable error handling in stacks involving D-Bus and Flatpak runtimes.
Because of its stable C ABI and metadata emitted by introspection, GLib is accessible from many languages. Common bindings include Python (programming language) through PyGObject, JavaScript via GJS, Rust (programming language) projects using wrappers in the gtk-rs ecosystem, and Vala (programming language). Integrations extend to systems like GStreamer media pipelines, GTK+ widgets, and higher-level frameworks such as GNOME Shell and Anaconda (installer). The GObject Introspection repository enables automatic generation of bindings for languages including Perl, Ruby, Lua, and C#, which is used in Mono (software) projects.
GLib is ubiquitous in the GNOME ecosystem and adopted by diverse projects beyond desktop environments. It is foundational in multimedia stacks like GStreamer, networking daemons like NetworkManager, and content systems such as Tracker (search engine). Embedded projects and distributions, for example Yocto Project-based builds and various OpenWrt packages, use GLib for portability. Commercial entities including Red Hat, SUSE, and integrators building cross-platform graphical tools rely on GLib for core services. Its event-driven main loop, thread abstractions, and GIO networking make it suitable for GUI applications, headless daemons, and multimedia servers used in environments from personal desktops running Fedora and Ubuntu to appliances and mobile devices derived from Moblin-era initiatives.
Category:Software libraries