Topics / Embedded Linux & Boot / Q15
What is the difference between glibc, musl and uClibc-ng?
Short answer: All three are C standard libraries for Linux. glibc is the most complete and compatible but the largest. musl is small, clean and easy to link statically, with strict standards behaviour. uClibc-ng targets very small systems, including MMU-less (noMMU) Linux. The choice affects image size, compatibility with existing software, and licensing.
| glibc | musl | uClibc-ng | |
|---|---|---|---|
| Size | large (~2 MB+ shared) | small (~1 MB, tiny static binaries) | small, very configurable |
| Compatibility | reference; almost all software assumes it | high, but some glibc extensions missing or different | good for common software |
| Static linking | possible but awkward (NSS, dlopen) |
designed for it | supported |
| noMMU support | no | limited | yes |
| Locale/i18n | full | basic (UTF-8 only) | configurable |
| License | LGPL-2.1 | MIT | LGPL-2.1 |
| Used by | most distros, Yocto default | Alpine Linux, many Buildroot/OpenWrt images | old OpenWrt, very small devices |
Practical points
- Binary compatibility: a program built against glibc will not run on a musl system (different dynamic loader and symbol versions), and vice versa. Pick one per image.
- Behaviour differences seen in practice: DNS resolver details, smaller default thread stack size in musl (128 KB),
dlclose()not unloading, some GNU-only functions missing. - Licensing: LGPL requires that users can relink your application with a modified library. With dynamic linking that is easy; with static linking against glibc you must provide object files. musl's MIT license avoids this, which is one reason for its use in products.
- Bare-metal is different: Cortex-M firmware uses newlib or newlib-nano (or picolibc), not these Linux libraries.
How to answer "which would you choose": glibc for compatibility with third-party and vendor software (and when a vendor SDK requires it); musl for small, statically linked, security-focused or container images; uClibc-ng only for very constrained or noMMU targets.