The relationship between X-based GNOME, GTK, GDK, XLib, GLib, etc.

widgets Article
The relationship between X-based GNOME, GTK, GDK, XLib, GLib, etc.

There are many common libraries under Linux,

libc, glibc; glib, gdk, gtk, too many. But these libraries are hierarchical.

1. libc & glibc

libc is the ANSI C library under Linux ; glibc is the GUN C library under Linux.

glibc is the implementation of the C standard library under Linux, namely the GNU C Library. glibc itself is the C standard library of GNU, and later gradually became the standard c library of Linux, and the original standard c library Linux libc under Linux is gradually no longer maintained . The standard c libraries under Linux not only have this one, such as uclibc, klibc, and the Linux libc mentioned above, but glibc is undoubtedly the most used . The .so file of glibc in the / lib directory is libc.so.6.

Notice: glibc and glib are different. In fact, glib and glibc are basically not related. The only thing they may have in common is that they are all libraries that C programming needs to call. glib is the foundation of the Gtk + library and Gnome. glib can be used on multiple platforms, such as Linux, Unix, Windows, etc. glib provides corresponding replacements for many standard and commonly used C language constructs.

2. glib, gdk, gtk, gnome

simply put:

xlib: The X Library is the lowest-level API of the X Window program. If compared with Windows, Xlib is the same as the Windows APIs (or Windows SDK). It is the programming interface that is closest to X Server. It only provides the most Basic drawing and handling of message events.

glib: a utility library for C under Linux , including portability and some utility functions, as well as some container classes, such as: linked lists, variable arrays, variable-length strings, hash tables, cache, an event loop, and others Useful structure. glib is some utilities written in C, that is, C tool library, and has nothing to do with libc / glibc.

gdk:  simply wraps the Xlib function library, and it is only used when we do special painting or set special properties of the window.

gtk: It is part of the GTK + library. This library provides basic toolkits and widgets to create GUI applications. Most GUIs are written directly in GTK. GTK also provides a powerful object system for the Gnome library.

Below the dividing line are reproduced:

What is Xlib?
The X Library is the lowest-level API of the X Window program. If compared with Windows, Xlib is the same as the Windows APIs (or Windows SDK). It is the programming interface closest to X Server. It only provides the most basic. Handling of drawing and message events.

What is Xt? (X Toolkit Intrinsics)
Xt is the first library to wrap Xlib into a more abstract function library. It provides an "object-oriented" programming framework and introduces a concept called "widget". This "widget" data structure is also called "User Interface Componets" like widgets such as menus, buttons or TextBox. Since then, programmers can use the concept of widgets to structure our applications, making the program simple and easy to understand.
However, Xt only defines how the application communicates with these widgets. It does not specify how the widgets will look. In the end, the real appearance of these widgets still has to be handled by higher-level libraries. (Usually provides a library of widgets, which we call GUI Toolkit (X ToolKits).
Motif, OpenLook, and Lesstif are all graphical interface libraries derived from Xt Library

Motif
Motif is currently the most important GUI Toolkit. It is based on Xt's widget concept and provides a graphical interface that looks very similar to Microsoft Windows 95. Motif is produced by the Open Group (formerly Open Software Foundation).
But now Motif is not just a GUI Toolkit, it also includes a Motif window manager (window manager) for managing X Clients (X Applications).

What is GDK?
GDK is a basic wrapper for standard Xlib function calls. If you are familiar with Xlib, you do not need to re-familiarize with most GDK functions. All functions are to provide a convenient and intuitive style To access the Xlib function library. In addition, since GDK uses GLib, GDK becomes more convenient and safe when used on multiple platforms.

What is GLib? The
GLib library provides a series of functions (functions) and definitions (definitions), in It is useful when designing GDK and GTK programs. It provides some alternative functions of standard c function library (standard libc), such as malloc, but there are many problems when used on other systems.

What is GTK +?

GTK + is a small and efficient The control library has the appearance and style of Motif. In fact, it looks much better than Motif. It contains basic controls and some very complex controls: such as file selection, controls, and color selection controls. GTK + provides some Unique features, (at least, I know that other control libraries do not provide them), for example, the button does not provide a label, it contains a sub-control, in many cases it is a label, but this sub-control can also be a mapping , Images, or any other collection that programmers want. You can see this scalability everywhere in the entire library.
Gnome's development infrastructure is centered around a set of function libraries. All content is written in the portable ANSI C language and can be used in all UNIX-like systems. Graphics-related function libraries depend on the X Window system. The Gnome function library is the highest level. GTK + consists of two parts, GTK and GDK. The GTK layer provides an object model for the C language and the most basic widget for the UI toolkit, which is the basis for the upper-level GUI derivation. GTK is dependent on GDK, which is a low-level package of Xlib, and the Xlib library talks directly with the X server. Any part except Xlib is based on GLib, it is a useful C function library, provides a lot of utility programs and portable functions and a set of containers easily used by C language.

Yi Ge Gnome program is a hierarchy using multiple libraries consisting of:

GNOME (GNU Network Object Model Environment) is a graphical interface library based on GTK. Like KDE, GNOME is also aimed at creating a complete and friendly graphical environment and provides GNOME related software.
The Gnome library is at the highest level and includes help routines, classes and special widgets, and provides an infrastructure for the application.
The second layer is GTK, which is part of the GTK + library. This library provides basic toolkits and widgets to create GUI applications. Most GUIs are written directly in GTK. GTK also provides a powerful object system for the Gnome library.
The next layer is GDK, which simply wraps the X function library. It will be used only when we make special paintings or set special properties of the window. The
bottom layer is Glib, which is a C Utility library, including portability and some utility functions, as well as some container classes, such as: linked lists, variable arrays, variable-length strings, hash tables, cache, an event loop, and other useful structures.

[Glibc and libc] Both glibc and libc are C function libraries under Linux. libc is the ANSI C library under Linux; glibc is the GUN C library under Linux. What is the difference between ANSI C and GNU C?

The ANSI C function library is a basic C language function library, which contains the most basic C language library functions. This library can be divided into 15 parts according to header files, including:

1. <ctype.h>: Contains the function prototype for testing a characteristic character, and the function prototype for converting upper and lower case letters;
2. <errno.h>: Define the macro used to report the error condition;
3. <float.h>: Contains the system's floating point size limit;
4. <math.h>: Function prototype containing math library functions;
5. <stddef.h>: Contains common function definitions used to perform certain calculations C;
6. <stdio.h>: Contains function prototypes of standard input and output library functions, and the information they use;
7. <stdlib.h>: Contains function prototypes for converting numbers to text and text to numbers, as well as function prototypes for memory allocation, random numbers, and other practical functions;
8. <string.h>: function prototype containing string processing functions;
9. <time.h>: Contains function prototypes and types of time and date operations;
10. <stdarg.h>: Contains function prototypes and macros, and is used to process parameter lists of functions with unknown values ​​and types;
11. <signal.h>: Contains function prototypes and macros, used to process various conditions that may occur during program execution;
12. <setjmp.h>: contains prototypes of functions that can bypass general function calls and return sequences, ie non-local jumps;
13. <locale.h>: Contains function prototypes and other information, so that the program can be modified for the region where it runs.
14. The representation method of the region can enable the computer system to process different data expression conventions, such as the date, time, dollar number and large number in the world;
15. <assert.h>: Contains macros and information, used for diagnosis and help program debugging.
The above library functions are available in various IDEs that support the C language.        The GNU C library is something similar to third-party plug-ins. Since Linux is written in C language, some operations of Linux are implemented in C language. Therefore, GUN organization has developed a C language library so that we can make better use of C language to develop programs based on Linux operating system.

However, the current different Linux distributions have different treatments for these two libraries, and some may have been integrated into the same library.

glibc is the implementation of the C standard library under Linux, namely the GNU C Library. glibc itself is the C standard library of GNU, and later gradually became the standard c library of Linux, and the original standard c library Linux libc under Linux is gradually no longer maintained . The standard c libraries under Linux not only have this one, such as uclibc, klibc, and the Linux libc mentioned above, but glibc is undoubtedly the most used . The .so file of glibc in the / lib directory is libc.so.6.

There are two ways to view the glibc version of the current system: 1.

 01 [root@Betty ~]# /lib/libc.so.6
 02 GNU C Library stable release version 2.5, by Roland McGrath et al.
 03 Copyright (C) 2006 Free Software Foundation, Inc.
 04 This is free software; see the source for copying conditions.
 05 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
 06 PARTICULAR PURPOSE.
 07 Compiled by GNU CC version 4.1.2 20080704 (Red Hat 4.1.2-52).
 08 Compiled on a Linux 2.6.9 system on 2013-01-08.
 09 Available extensions:
 10         The C stubs add-on version 2.1.2.
 11         crypt add-on version 2.1 by Michael Glad and others
 12         GNU Libidn by Simon Josefsson
 13         GNU libio by Per Bothner
 14         NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
 15         Native POSIX Threads Library by Ulrich Drepper et al
 16         BIND-8.2.3-T5B
 17         RT using linux kernel aio
 18 Thread-local storage support included.
 19 For bug reporting instructions, please see:
 20 .
 21 [root@Betty ~]#
2.
 1 [root@Betty ~]# ldd  --version
 2 ldd (GNU libc) 2.5
 3 Copyright (C) 2006 Free Software Foundation, Inc.
 4 This is free software; see the source for copying conditions.  There is NO
 5 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 6 Written by Roland McGrath and Ulrich Drepper.
 7 [root@Betty ~]#

[Glibc and glib]       wrong view: there is a "g" in front of glib, so glib is regarded as the stuff of GNU; at the same time, glibc is regarded as a subset of glib.       In fact, glib and glibc are basically not related, and the only thing they may have in common is that they are all libraries that C programming needs to call. glib is the foundation of the Gtk + library and Gnome. glib can be used on multiple platforms, such as Linux, Unix, Windows, etc. glib provides corresponding replacements for many standard and commonly used C language constructs.

glib is the basic library of GTK + . It consists of five parts: basic types, support for core applications, practical functions, data types and object systems . You can  download the source code at [ http://www.gtk.org gtk website] . It is a comprehensive and practical lightweight C library , which provides the definition of commonly used data structures in C language, related processing functions, interesting and practical macros, portable packaging and some runtime functions, such as events API loop, threads, dynamic invocation, the target system . GTK + is portable, and of course glib is also portable. You can use it under linux or under windows. Applications written using gLib2.0 (version 2.0 of glib), at should be added to the compile command during compilationpkg-config --cflags --libs glib-2.0 , such as:

gcc  pkg-config --cflags --libs glib-2.0  hello.c -o hello

The most famous use of glib is GNOME.

[Official description]

Glib

GLib is a general-purpose utility library, which provides many useful data types, macros, type conversions, string utilities, file utilities, a main loop abstraction, and so on. It works on many UNIX-like platforms, Windows, OS / 2 and BeOS. GLib is released under the GNU Library General Public License (GNU LGPL).
The general policy of GLib is that all functions are invisibly threadsafe with the exception of data structure manipulation functions, where, if you have two threads manipulating the same data structure, they must use a lock to synchronize their operation.
GLib is the low-level core library that forms the basis for projects such as GTK + and GNOME. It provides data structure handling for C, portability wrappers, and interfaces for such runtime functionality as an event loop, threads, dynamic loading, and an object system.

Glibc
Overview:
Any Unix-like operating system needs a C library: the library which defines the  system calls '' and other basic facilities such as open, malloc, printf, exit ...
The GNU C Library is used as the C library in the GNU systems and most systems with the Linux kernel.
Project Goals:
The GNU C Library is primarily designed to be a portable and high performance C library. It follows all relevant standards including ISO C11 and POSIX.1-2008. It is also internationalized and has one of the most complete internationalization interfaces known.
History:
The history of Unix and various standards determine much of the interface of the C library. In general the GNU C Library supports the ISO C and POSIX standards. We also try to support the features of popular Unix variants (including BSD and System V ) when those do not conflict with the standards. Different compatibility modes (selectable when you compile an application) allow the peaceful coexistence of compatibility support for different varieties of Unix.

[Other statements]

libc is actually a general term. Any content that meets the requirements of the C standard is a libc.
glibc is an implementation of libc by the GNU organization. It is one of the foundations of unix / linux.
Microsoft also has its own libc implementation, called msvcrt.
UClibc is also commonly used in the embedded industry, it is a mini version of libc.

【Yasi】

Libc and glibc are at the same level. They are all C standard implementation libraries and one of the cornerstones of the operating system level.

glib is some utilities written in C, that is, C tool library, and libc / glibc has nothing to do.