glibc, glib and gnulib

我是研究僧i 提交于 2019-11-30 11:21:18

问题


what are differences in the strength and features in gnulib glib and glibc Thanks!


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/2240120/glibc-glib-and-gnulib

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!