glibc, glib and gnulib

glibc is a core C runtime library. It provides things like printf(3) and fopen(3).

glib is an object-based event loop and utility library written in C.

gnulib is a library that provides an adapter from the POSIX API to the native API.

All three are used for completely different tasks.


glibc, the shortened form of GNU C Library, is the GNU Project's implementation of the C standard library. The API of the C standard library is declared in familiar header files like <stdio.h> and <stdlib.h> (see the Wikipedia link for a full list of header files).

The POSIX operating system API is provided through <unistd.h> which mainly wraps system calls like fork and I/O operations like read/write.

GLib is a bundle of system libraries written in C and developed by GNOME (part of the GNU Project). Quoting from Wikipedia (without source unfortunately)

GLib provides advanced data structures, such as memory chunks, doubly and singly linked lists, hash tables, dynamic strings and string utilities, such as a lexical scanner, string chunks (groups of strings), dynamic arrays, balanced binary trees, N-ary trees, quarks (a two-way association of a string and a unique integer identifier), keyed data lists, relations, and tuples. Caches provide memory management.

GLib implements functions that provide threads, thread programming and related facilities such as primitive variable access, mutexes, asynchronous queues, secure memory pools, message passing and logging, hook functions (callback registering) and timers. GLib also includes message passing facilities such as byte order conversion and I/O channels.

Some other features of GLib include:

  • standard macros
  • warnings and assertions
  • dynamic loading of modules

Why use GLib functions?

Gnulib, also called the GNU Portability Library, is a collection of GNU code to assist with writing portable code. From the manual:

Gnulib is intended to be the canonical source for most of the important “portability” and/or common files for GNU projects. These are files intended to be shared at the source level; Gnulib is not a typical library meant to be installed and linked against. Thus, unlike most projects, Gnulib does not normally generate a source tarball distribution; instead, developers grab modules directly from the source repository.

Many of the functions implement portability workarounds for ISO C and POSIX functions.

Tags:

Glibc

Glib