- Mastering Embedded Linux Programming
- Chris Simmonds
- 396字
- 2021-07-30 09:44:59
Choosing the C library
The programming interface to the Unix operating system is defined in the C language, which is now defined by the POSIX standards. The C library is the implementation of that interface; it is the gateway to the kernel for Linux programs, as shown in the following diagram. Even if you are writing programs in another language, maybe Java or Python, the respective run-time support libraries will have to call the C library eventually:

The C library is the gateway to the kernel for applications
Whenever the C library needs the services of the kernel it will use the kernel system call
interface to transition between user space and kernel space. It is possible to bypass the C library by making kernel system calls directly, but that is a lot of trouble and almost never necessary.
There are several C libraries to choose from. The main options are as follows:
- glibc: Available at big and, until recently, not very configurable, but it is the most complete implementation of the POSIX API.
- eglibc: Available at of patches to glibc which added configuration options and support for architectures not covered by glibc (specifically, the PowerPC e500). The split between eglibc and glibc was always rather artificial and, fortunately, the code base from eglibc has been merged back into glibc as of version 2.20, leaving us with one improved library. eglibc is no longer maintained.
- uClibc: Available at that this is the micro controller C library. It was first developed to work with uClinux (Linux for CPUs without memory management units), but has since been adapted to be used with full Linux. There is a configuration utility which allows you to fine-tune its features to your needs. Even a full configuration is smaller than glibc but it is not as complete an implementation of the POSIX standards.
- musl libc: Available at designed for embedded systems.
So, which to choose? My advice is to use uClibc only if you are using uClinux or if you have very limited amounts of storage or RAM and so the small size would be an advantage. Otherwise, I prefer to use an up-to-date glibc, or eglibc. I have no experience of musl libc but if you find that glibc/eglibc is not suitable, by all means give it a go. This process is summarized in the following figure:

Choosing a C library
- Learn Blockchain Programming with JavaScript
- Flutter開發(fā)實戰(zhàn)詳解
- Android應(yīng)用程序開發(fā)與典型案例
- C語言程序設(shè)計(第2 版)
- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- Raspberry Pi Networking Cookbook(Second Edition)
- 羅克韋爾ControlLogix系統(tǒng)應(yīng)用技術(shù)
- Mastering Kotlin
- 基于免疫進化的算法及應(yīng)用研究
- Internet of Things with the Arduino Yún
- 假如C語言是我發(fā)明的:講給孩子聽的大師編程課
- 你不知道的JavaScript(中卷)
- Swift語言實戰(zhàn)精講
- Corona SDK Mobile Game Development:Beginner's Guide(Second Edition)
- Learning Apache Cassandra