Skip to content

19 extra libs

misazhu edited this page Dec 3, 2026 · 4 revisions

19 EwokOS's Extra Libraries (projects)

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).

19.1 The Extension Submodule

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 full make and go into the rootfs; extension libraries are "optional equipment" — you only compile them when you want to run the corresponding applications.

19.2 Where sw.extra's Libraries Went

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)

curses — Text Terminal UI (now a core library)

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.

The SDL2 Family — a Cross-Platform Multimedia Layer

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}).

19.3 projects' Libraries

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's DIRS lists 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, use make projs <dir> ... / make clean projs <dir> ... from the machine's system/ directory (see 19.5).

browser — Web Browsing

projects/browser/libs/:

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.

saver — Screensaver (2D Physics + GL Math)

projects/saver/libs/:

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.

opengl — Software 3D Rendering

projects/opengl/libs/:

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.

video — Video Playback

projects/video/libs/:

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.

Emulators and Games (No Dedicated libs)

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.

19.4 Extension-Library Quick Reference

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

19.5 How to Use the Extension Libraries

Extension libraries don't go into the core rootfs; the usage is "cross-compile against the SDK + link into your application":

  1. Build the core system first, ensuring the SDK (system/build_<arch>/<hw>/{include,lib}) is ready;
  2. Enter the corresponding library/app directory and make: the extension libraries' Makefiles include the platform's make.rule, finding core headers with -isystem $(SDK_DIR)/include and core libraries with -L $(SDK_DIR)/lib;
  3. Add the extension libraries' .a at link time — e.g. an SDL program links -lSDL2 -lSDL2_image -lSDL2_mixer ... in addition to EWOK_LIB_GRAPH/EWOK_LIB_X.

projects is driven by make projs from the machine's system/ build directory: it builds every dir in projects/Makefile's DIRS, stages the apps into the rootfs and refreshes build_<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. Run make projs from the machine's system/ directory, not from projects/ itself: the machine make.inc exports the capability flags (ARCH/HW, PGL_G3D, ...) that the GPU backends are gated on.

19.6 Summary

  • The former sw.extra submodule is gone: curses (text UI) is now a core gui library, the SDL2 family (SDL2/image/mixer/ttf/gfx multimedia), the browser and git live in projects, and vim was rewritten as a small standalone editor in system/gui/bin;
  • projects (the ewokos.projects submodule): libraries travel with their apps — browser uses litehtml+gumbo, saver uses cglm+ferox, opengl uses portablegl+imgui+glcommon, video uses ffmpeg and the widget++ 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 操作系统教学

English Home · 中文首页

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 / 附录

Clone this wiki locally