Repository navigation
18 libs
Language: English | 中文
Goal: take stock of the "wheels" EwokOS has prepared above libc — filesystems, image codecs, fonts, 2D drawing, window widgets, network protocols, C++ support. After reading you'll know: when you want to do something, which directory to look in for which library, and which
-lxxxto link. This is the third (final) article of the "ewokos series".
16 gave the map; 17 covered the bottommost libc. This chapter introduces the common libraries layer by layer, by "library settlement". All libraries follow the uniform directory structure from §16.3.
Low-level libraries dealing with hardware, filesystems, and data formats
(system/basic/libs/). The build list is in
libs/Makefile's DIRS.
| Library | Link name | Headers | Purpose |
|---|---|---|---|
| sd | -lsd |
sd/sd.h, sd/gpt.h, sd/partition.h
|
SD card / block device read-write, GPT and MBR partition-table parsing (Ch. 10) |
| ext2 | -lext2 |
ext2/ext2fs.h, ext2/ext2head.h
|
ext2 filesystem read-write (the rootfs is ext2) |
| ext3 | -lext3 |
ext3/... |
the ext3 filesystem (ext2 with journaling) |
| fat32 | -lfat32 |
fat32/fat32fs.h, fat32/fat32head.h
|
the FAT32 filesystem (USB sticks, SD card FAT partitions) |
| elf | -lelf |
elf/elf.h |
parsing and loading the ELF executable format (used by Ch. 07's exec) |
Dependencies:
ext2andext3are both built on the block-device access provided bysd, hence the Makefile lineext2 ext3: sd.
| Library | Link name | Headers | Purpose |
|---|---|---|---|
| tinyjson | -ltinyjson |
tinyjson/tinyjson.h |
lightweight JSON parsing/generation. All of the system's .json configs rely on it (chapters 10, 13) |
| zlib | -lz |
zlib.h |
the classic compression library: deflate/inflate, gzip, the underlying dependency of PNG |
| openlibm | -lopenlibm |
math.h |
the math library libm (introduced in Ch. 17) |
| Library | Link name | Headers | Purpose |
|---|---|---|---|
| gpio | -lgpio |
gpio/gpio.h |
GPIO pin read-write (light LEDs, read buttons, bit-bang protocols) |
EwokOS's GUI and quite a few applications are written in C++, and the C++ runtime also lives in the basic libraries (system/basic/libs/c++/):
| Library | Link name | Purpose |
|---|---|---|
c++/c++ |
(the C++ runtime) | C++ language runtime support (cxx.cc: construction, exception tables, RTTI, and other infrastructure) |
c++/stl |
-lewokstl |
EwokOS's trimmed STL (containers, algorithms) |
c++/object++ |
(UniObject) |
UniObject — bidirectional object↔JSON binding/reflection, depends on tinyjson |
Dependency chain:
c++/stlandc++/object++both depend onc++/c++;object++additionally depends ontinyjson.
2D drawing, fonts, image codecs, display, and input
(system/gui/libs/). The build list is in
gui/libs/Makefile. This whole layer is
linked as a bundle via EWOK_LIB_GRAPH.
| Library | Link name | Headers | Purpose |
|---|---|---|---|
| graph | -lgraph |
graph/graph.h, graph_image.h, graph_ex.h, rgb24.h, rgb15.h, uv12.h
|
the 2D graphics core: points/lines/rectangles, bit blits (blt), alpha blending, color-space conversion, and loading PNG/JPEG/GIF/TGA/SVG (Ch. 13) |
| g2dclient | -lg2dclient |
graph/graph_g2d.h |
the 2D graphics hardware acceleration client (offloads blt/fill to the g2d driver) |
| libiconbuf | -liconbuf |
iconbuf/iconbuf.h |
the icon buffer: load/cache icon resources |
| Library | Link name | Headers | Purpose |
|---|---|---|---|
| font | -lfont |
font/font.h |
text rendering: draw strings into bitmaps, manage fonts/sizes/colors |
| freetype | -lfreetype |
(FreeType) | the industry-standard TrueType/OpenType font rasterization engine, font's foundation |
| Library | Link name | Purpose |
|---|---|---|
| libpng | -lpng |
PNG encode/decode (depends on zlib) |
| libjpeg | -ljpeg |
JPEG decoding |
| libgif | -lgif |
GIF decoding |
| libtga | -ltga |
TGA (Targa) images |
| libsvg | -lsvg |
SVG vector rendering (based on plutovg) |
| Library | Link name | Headers | Purpose |
|---|---|---|---|
| display | -ldisplay |
display/display.h |
the display-device abstraction (resolution, color depth, flipping) |
| displayman | -ldisplayman |
displayman/displayman.h |
display management (multiple outputs / dynamic timings) |
| displayd | (driver) | — | the display-daemon-side library |
| textgrid | -ltextgrid |
textgrid/textgrid.h, text_content.h
|
the character grid: a terminal's "rows/columns + characters" model |
| gterminal | -lgterminal |
gterminal/gterminal.h |
the graphical terminal: renders a textgrid with font/graph |
| Library | Link name | Purpose |
|---|---|---|
| keyb | -lkeyb |
keyboard input |
| mouse | -lmouse |
mouse input |
| minimp3 | — | MP3 decoding (single header) |
| libogg / libvorbis |
-logg/-lvorbis
|
the OGG container and Vorbis audio decoding |
Dependencies (from the Makefile):
graphdepends on the image codec libraries andg2dclient;fontdepends onfreetype;display/libiconbufdepend ongraph;textgrid/gterminaldepend onfont+graph, andgterminaldepends ontextgrid.
The bus stacks live in the graphics layer as well, because the daemons that
consume them (usbhostd, btd, hid_keybd/hid_moused/hid_touchd,
usbfat32fsd) are built here:
| Library | Link name | Headers | Purpose |
|---|---|---|---|
| usb | -lusb |
usb/usb_defs.h, usb/bsp_usb.h, usb/usbhid.h, usb/usbhidsrv.h
|
the USB host stack and HID (keyboard/mouse) device support |
| hid | -lhid |
hid/hid_defs.h, hid/hid_report.h, hid/hid_srv.h
|
bus-independent HID report parsing plus the subscriber-queue service shared by the USB and bluetooth daemons |
| bt | headers only | bt/bsp_bt.h |
the per-machine bluetooth HCI transport contract that every libbsp implements |
The X-style window system's client libraries and the C++ widget toolkit
(system/xwin/libs/). The build chain: x →
x++ → widget++, linked as a bundle via EWOK_LIB_X (Ch. 13).
| Library | Link name | Headers | Purpose |
|---|---|---|---|
| x | -lx |
x/x.h, xwin.h, xevent.h, xwm.h, xtheme.h, xcntl.h
|
the window system's C interface: create windows, send/receive events, interact with the window manager/themes |
| x++ | -lx++ |
x++/X.h, XWin.h, XWM.h, XTheme.h
|
a C++ wrapper of x, operating windows object-orientedly |
| widget++ | -lwidget++ |
Widget/*.h |
the C++ widget toolkit: ready-made UI components |
The widgets widget++ provides (include/Widget/) are quite complete:
Widget (base) Container WidgetWin / RootWidget / WidgetX
Button RoundButton LabelButton RoundLabelButton Label Image
Text EditLine List ListBase Scroller Scrollable Slider
Grid Columns Split Splitter Stage Blank SpriteAnim SpriteWin
To write a graphical app with buttons, lists, and input fields, just assemble these widgets — no need to start from drawing pixels.
Network protocols and upper-level application protocols (system/network/libs/). The build list is in network/libs/Makefile.
| Library | Link name | Purpose |
|---|---|---|
| socket | -lsocket |
the BSD socket API: socket/bind/connect/listen/accept/send/recv, plus inet_ntop/inet_pton/inet_ntoa. Underneath is the userland netd protocol stack (Ch. 09 IPC + the network daemon) |
| ntpc | -lntpc |
an NTP client: synchronize time with a time server |
| wolfssl | -lwolfssl |
an embedded TLS/SSL library (wolfSSL), providing HTTPS/encryption capability |
| libtinyhttpsc | -ltinyhttpsc |
a lightweight HTTP server/client; can run on top of wolfSSL for HTTPS |
| libwebsockets | -lwebsockets |
a WebSocket library: full-duplex real-time communication |
Dependencies:
ntpc/wolfssl/libwebsocketsall needsocket's headers installed first;libtinyhttpscdepends on bothsocketandwolfssl.
| I want to… | Use this library | Link |
|---|---|---|
| read/write the SD card / parse partitions | sd | -lsd |
| read/write ext2/ext3/FAT32 files | ext2 / ext3 / fat32 |
-lext2 etc. |
| parse/load ELF executables | elf | -lelf |
| parse JSON configs | tinyjson | -ltinyjson |
| compress/decompress (gzip, zip, PNG's foundation) | zlib | -lz |
| do math (sin/cos/sqrt) | openlibm | -lopenlibm |
| light LEDs / read GPIO | gpio | -lgpio |
| attach USB keyboards/mice/HID | usb | -lusb |
| draw points/lines/shapes, blit, alpha blend | graph |
-lgraph (EWOK_LIB_GRAPH) |
| hardware-accelerated 2D blt/fill | g2dclient | -lg2dclient |
| render TrueType fonts/text | font + freetype | -lfont -lfreetype |
| decode PNG/JPEG/GIF/TGA/SVG | libpng/libjpeg/libgif/libtga/libsvg |
-lpng etc. |
| operate the display/framebuffer | display / displayman / fb |
-ldisplay etc. |
| build a character terminal | textgrid + gterminal | -lgterminal |
| read keyboard/mouse | keyb / mouse | -lkeyb -lmouse |
| play MP3/OGG audio | minimp3 / libogg+libvorbis | — |
| open windows, send/receive window events | x / x++ |
-lx -lx++ (EWOK_LIB_X) |
| use ready-made UI widgets (buttons/lists/input fields) | widget++ | -lwidget++ |
| send TCP/UDP packets | socket | -lsocket |
| do HTTPS / encryption | wolfssl + libtinyhttpsc | -lwolfssl -ltinyhttpsc |
| do WebSocket real-time communication | libwebsockets | -lwebsockets |
| synchronize time over NTP | ntpc | -lntpc |
| use C++ / STL / object-JSON binding | c++ / stl / object++ |
-lewokstl etc. |
What this chapter lists are the libraries shipped with the core system. The repo also has a separate submodule projects/, collecting larger third-party suites and applications, for example:
-
SDL2 (projects/sdl2/, built
in the
projectsphase) — a cross-platform multimedia/game development layer; -
litehtml/gumbo (browser), ffmpeg (video), portablegl (3D) and
the
widget++extension widgets — see 19.
The former sw.extra submodule has been removed: curses
(system/gui/libs/curses/, libcurses +
libterminfo) is now a core gui library, and vim lives in
system/gui/bin/vim/.
The projects suites are likewise vendored as source and cross-compiled
with customized Makefiles, but they count as "extended software" — not
part of the core system/ build chain, enabled on demand.
-
Basic libraries (
basic/libs): filesystems (sd/ext2/ext3/fat32/elf), data (tinyjson/zlib), math (openlibm), hardware (gpio/usb), C++ (c++/stl/object++); -
Graphics libraries (
gui/libs): the drawing core graph + g2dclient, fonts font+freetype, image codecs png/jpeg/gif/tga/svg, display display/fb, terminals textgrid/gterminal, input keyb/mouse, audio minimp3/ogg/vorbis — uniformly linked viaEWOK_LIB_GRAPH; -
Window libraries (
xwin/libs): x → x++ → widget++ (rich C++ widgets), linked viaEWOK_LIB_X; -
Network libraries (
network/libs): socket, ntpc, wolfssl, libtinyhttpsc, libwebsockets; - Bigger third-party suites (SDL2, litehtml, ffmpeg…) are in the separate
submodule
projects/; curses is now part ofgui/libs.
That concludes the three articles of the "ewokos series": you now hold a complete map from libc to the common libraries. What next? Go back to 15 Debugging and the Road Ahead, or pick a library and read its source — they're all small with clear structures, perfect as advanced exercises.
EwokOS OS Tutorial / EwokOS 操作系统教学
Part 1: Getting Started / 第 1 部分:起步
Part 2: The Kernel / 第 2 部分:内核
Part 3: Userland / 第 3 部分:用户态
Part 4: The Full System / 第 4 部分:完整系统
Part 5: The ewokos Series (Libraries) / 第 5 部分:ewokos 系列(库生态)
Part 6: GPU & Compute / 第 6 部分:GPU 与计算
Appendix / 附录