Repository navigation
19 extra libs
Language: English | 中文
Goal: take stock of the libraries shipped in the "extension" submodule outside the core system —
projects(more applications): SDL2, an HTML engine, 3D, physics, a multimedia framework… This is the fourth article of the "ewokos series", following 18's core libraries.
There used to be a second extension submodule, sw.extra; it has been
removed. Its useful parts were absorbed into the main tree (curses
into system/gui/libs/, SDL2/browser/git into projects/), and the rest
(calculator, calendar, doom, mario_vm) was dropped. What remains is
projects: an independent git submodule, not part of the core
system/ build chain, enabled on demand. It vendors a batch of
"heavyweight" third-party libraries for advanced applications (a
browser, a video player, 3D, emulators).
| Submodule | Directory | Positioning | Built by default? |
|---|---|---|---|
| ewokos.projects | projects/ | more applications: browser, video, screensaver, software 3D, GPU API stacks, plus a bunch of emulators and games | whatever projects/Makefile's DIRS lists gets built (via make projs) |
It follows the "manual, source-level dependency management" from Ch.
16: third-party libraries are vendored into the
directories as source, cross-compiled into static .a against the EwokOS
SDK with customized Makefiles, then linked into their respective
applications. They depend at compile time on the SDK already installed by
the core system (system/build_<arch>/<hw>/{include,lib}), so you must
build system/ first before building the extensions.
The key difference from the core libraries: core libraries (
system/*/libs) are built with a fullmakeand go into the rootfs; extension libraries are "optional equipment" — you only compile them when you want to run the corresponding applications.
When sw.extra was removed, its libraries were relocated:
| Old location | New location | Status |
|---|---|---|
sw.extra/libs/curses |
system/gui/libs/curses/ | now a core gui library, built with the system |
sw.extra's SDL2 family |
projects/sdl2/ | built in the projects phase |
sw.extra's browser (ewebrowser) |
projects/browser/ | built in the projects phase |
sw.extra's git |
projects/git/ | built in the projects phase |
sw.extra/bin/vim |
system/gui/bin/vim/ | rewritten as a small self-contained vim (no curses dependency) |
system/gui/libs/curses/ is a port of NetBSD curses, letting you draw "character interfaces" in a terminal (menus, panels, colored text). It consists of two static libraries:
| Library | Purpose |
|---|---|
| libcurses | screen drawing: windows, cursor, attributes, key input |
| libterminfo | terminal capability handling: parses the terminfo database, outputs escape sequences via tparm/tputs; also provides a termcap compatibility layer (tgetent/tgetstr/tgoto, etc.) |
Since it now sits in system/gui/libs, it is built and staged into the
SDK by the regular system build — no separate extension step needed.
projects/sdl2/ comes from the "Raspberry
Pi Baremetal" port — a complete set of SDL2 and its official extension
libraries, now built in the projects phase:
| Library | Link name | Purpose |
|---|---|---|
| SDL2 | -lSDL2 |
Simple DirectMedia Layer: a unified abstraction of windows/input/audio/timers/threads — the foundation of games and multimedia programs |
| SDL2_image | -lSDL2_image |
image loading: BMP/GIF/JPG/PNG/TGA/TIF/WEBP |
| SDL2_mixer | -lSDL2_mixer |
audio mixing: multi-channel playback, supporting MP3/OGG/AIFF/VOC etc. |
| SDL2_ttf | -lSDL2_ttf |
TrueType font rendering (based on FreeType) |
| SDL2_gfx | -lSDL2_gfx |
graphics primitives (lines/circles/polygons), rotozoom scaling/rotation, frame-rate control |
On EwokOS, SDL2 maps "windows/input/audio" onto the system's xwin, keyboard/mouse drivers, and audio services, letting SDL programs originally written for Linux/Windows be ported and run. The libraries and headers are installed into the system SDK (
system/build_$(ARCH)/$(HW)/{lib,include/SDL2}).
In projects (projects/), each application usually
carries its own libs/ with its dedicated third-party libraries. These
libraries are not in the core build chain — they compile together with
their own applications.
Note:
projects/Makefile'sDIRSlists everything built by default (sdl2, minivmac, macemu, nesemu, opengl, opencl, vulkan, imgui, games, ereader, video, cube, oled_saver, camera, browser, git, re3; saver and nx11 are currently commented out). To build or clean only selected projects, usemake projs <dir> .../make clean projs <dir> ...from the machine'ssystem/directory (see 19.5).
| Library | Purpose |
|---|---|
| litehtml | a lightweight HTML/CSS rendering engine: parses and lays out web pages, outputting a drawable document tree |
| gumbo | Google's HTML5 parser (ships with litehtml; parses HTML text into a tree) |
| widget++ | the browser project's local widget variant (works with litehtml for the web view) |
The corresponding app: projects/browser/apps/xBrowser.
| Library | Purpose |
|---|---|
| cglm | the OpenGL math library (C edition): vectors, matrices, quaternions, affine transforms, projections, etc. — the foundation of 3D/2D graphics computation |
| ferox | a 2D rigid-body physics engine (the FR_-prefixed API): worlds, collision detection (broadphase), dynamics, friction |
The corresponding app: projects/saver/apps/saver.
| Library | Purpose |
|---|---|
| portablegl | a software renderer implementing the OpenGL 3.x core profile in pure C — 3D without a GPU |
| imgui | Dear ImGui: an immediate-mode GUI, often used for debug panels/tool interfaces of 3D programs |
| glcommon | general GL helpers to go with portablegl (math, meshes, texture loading, etc.) |
The corresponding apps
(projects/opengl/apps/): classic 3D demos
like 3ddemo, gears, matrix, Fireworks, imgui_demo.
| Library | Purpose |
|---|---|
| ffmpeg | the industry-standard multimedia framework: demuxing and decoding audio/video (lib/ is the complete ffmpeg source + the EwokOS customized build ewok.mk) |
| widget++ | the video project's local widget variant: on top of the core widget++ (see 18.3) it adds two "heavyweight" widgets — WidgetWebview (a web view, embedding a browser engine to render pages) and WidgetVideo (video playback) |
The corresponding app: projects/video/apps/VideoPlayer, plus the library's own bin/mp4player.c.
The macemu / nesemu / minivmac (emulators) and games (cards,
mine) in projects don't carry their own libs/
directories: they link the core libraries directly (EWOK_LIBC /
EWOK_LIB_GRAPH / EWOK_LIB_X); the few needing multimedia capabilities
additionally link the SDL2 family from projects/sdl2. Their source code
itself is a fine example of "porting
- adapting to EwokOS", suitable for advanced reading.
| I want to… | Use this library | Where |
|---|---|---|
| build fullscreen text/character UIs (menus, panels) | curses (libcurses + libterminfo) |
system/gui/libs/curses (core) |
| write games/multimedia with SDL (cross-platform) | SDL2 + image/mixer/ttf/gfx | projects/sdl2 |
| embed web/video widgets in a window | widget++ (WidgetWebview/WidgetVideo) | projects/video/libs/widget++ |
| render HTML/CSS pages | litehtml + gumbo | projects/browser/libs |
| do 3D/2D graphics math | cglm | projects/saver/libs |
| add 2D physics (collisions, rigid bodies) | ferox | projects/saver/libs |
| run 3D without a GPU (software OpenGL) | portablegl + glcommon | projects/opengl/libs |
| add a debug UI to a 3D program | imgui (Dear ImGui) | projects/opengl/libs |
| decode/play audio and video | ffmpeg | projects/video/libs |
Extension libraries don't go into the core rootfs; the usage is "cross-compile against the SDK + link into your application":
-
Build the core system first, ensuring the SDK
(
system/build_<arch>/<hw>/{include,lib}) is ready; -
Enter the corresponding library/app directory and
make: the extension libraries' Makefilesincludethe platform'smake.rule, finding core headers with-isystem $(SDK_DIR)/includeand core libraries with-L $(SDK_DIR)/lib; -
Add the extension libraries'
.aat link time — e.g. an SDL program links-lSDL2 -lSDL2_image -lSDL2_mixer ...in addition toEWOK_LIB_GRAPH/EWOK_LIB_X.
projectsis driven bymake projsfrom the machine'ssystem/build directory: it builds every dir inprojects/Makefile'sDIRS, stages the apps into the rootfs and refreshesbuild_<arch>/. Both building and cleaning accept project names to act on a subset only:make projs # build all projects make projs vulkan opengl # build only vulkan and opengl make clean projs # clean only projects/, keep the system build make clean projs vulkan # clean only the named project(s)A selective build still honors
projects/Makefile's ordering edges (e.g.vulkan: opengl), so the staged libraries a project links against get an incremental pass first. Runmake projsfrom the machine'ssystem/directory, not fromprojects/itself: the machinemake.incexports the capability flags (ARCH/HW,PGL_G3D, ...) that the GPU backends are gated on.
- The former sw.extra submodule is gone:
curses(text UI) is now a core gui library, theSDL2family (SDL2/image/mixer/ttf/gfx multimedia), the browser and git live inprojects, and vim was rewritten as a small standalone editor insystem/gui/bin; -
projects (the ewokos.projects submodule): libraries travel with their
apps — browser uses
litehtml+gumbo, saver usescglm+ferox, opengl usesportablegl+imgui+glcommon, video usesffmpegand thewidget++extension widgets (WidgetWebview/WidgetVideo); emulators and games link the core libraries directly; - Extension libraries are optional equipment: not in the core build chain, cross-compiled against the installed SDK, linked on demand;
- At this point the "ewokos series" has covered the complete library landscape from libc through the core libraries to the extensions.
Want hands-on practice? Pick an extension app (say opengl's gears) and
read its Makefile and source — see how it wires portablegl onto EwokOS's
graph/xwin. That's the best example for understanding "how a library
lands".
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 / 附录