FAQ
Answers to the questions people run into first. Click a question to open its answer.
Installing
Every build fails with ZB0016: "unable to find zig installation directory"
The bundled Zig toolchain is incomplete. zig needs its lib folder beside zig.exe, and when bin\res\zig\lib\std\std.zig is missing every build fails with this message, which is zig's own.
To fix it:
- Delete the
bin\res\zigfolder. - Extract the release zip again with 7-Zip or WinRAR.
- Check that
bin\res\zig\lib\std\std.zigexists.
Building
The first build is slow
The first build for a target also compiles the libraries every program links (the C runtime, libc++, libc++abi, libunwind, compiler_rt and the system import libraries) and keeps them in zig's cache, bin\res\zig\.zig-cache. That build can take a few minutes.
Later builds for that target reuse them, at another optimize level too, and take seconds. The first build for the other target (x86_64-linux-gnu) compiles its own libraries once in the same way. Deleting bin\res\zig\.zig-cache makes the next build of each target slow again. How a build works is in Building.
Libraries
How do I load a library's files from assets.zip?
Mostly through HookIO (see Standard library), which hands C's fopen a zip entry (an IO from CreateZipFileIO). Which way depends on the library:
- mojoAL, SQLite, tmxlite and LDtkLoader: their
_extunit has a...Zipload form that takes the archive, the entry and the password (LoadSoundZip,OpenDatabaseZip,LoadTiledMapZip,LoadLdtkProjectZip), and an IO form beside it. See Vendor libraries. - raylib:
raylib_ext's IO forms (LoadTextureIOand the rest) overCreateZipFileIO, orSetRaylibIOSourceto make the zip raylib's file system. SFML:sfml_ext'ssfx::ZipStream. - Lua and yyjson: register the entry with
RegisterIOand pass itsio://path toluaL_loadfileoryyjson_read_file; they open files withfopen, so no extension unit is needed. - A SQLite database from a zip is read-only: SQLite opens files through its own layer, which HookIO does not reach, so
sqlite_extreads the entry into memory and hands it tosqlite3_deserialize.
The ...Zip examples in res\examples each load from the shared assets.zip.
A Lua error skips my C++ destructors
Lua's errors are C longjmps: lua_error, luaL_error and a failing luaL_check* jump out of the routine that calls them, past every C++ destructor between there and the lua_pcall. A routine Lua calls therefore checks its arguments first, before it makes anything that needs freeing (a string, a container, an object).
flecs' ECS_COMPONENT and ecs_set do not compile
They are flecs' C macros, built on C compound literals, which C++ rejects. Use flecs' C++ API instead (flecs::world, world.entity().set<T>(...), world.system<...>().each(...)), with PaskalCPP records as components; std\flecs.pcpp documents how a routine is written as an .each callback.
An ENet server does not reach a client that just connected
Each side gets its own CONNECT event when it services its host, and the client's often comes first. The server reaches (and broadcasts to) only the peers whose CONNECT it has seen, so wait for that event on the server before sending to the new peer.
Running Linux programs (WSL2)
A Linux window opens small under WSL2, and the program reads a display scale of 1
A Linux build run on Windows (-t x86_64-linux-gnu -r) runs under WSL2, and its window is shown by WSLg, whose compositor (Weston) gives every Linux program a display scale of 1 by default. A program that sizes its window by that scale (the SDL3 examples call SDL_GetWindowDisplayScale) opens at 1x on a 150% monitor, smaller than the same program built for Windows.
To make WSLg follow each monitor's Windows scale, create the file .wslgconfig in your Windows user folder (C:\Users\<you>\.wslgconfig for WSL from the Microsoft Store; C:\ProgramData\Microsoft\WSL\.wslgconfig for the WSL built into Windows) holding:
[system-distro-env]
WESTON_RDP_HI_DPI_SCALING=true
WESTON_RDP_FRACTIONAL_HI_DPI_SCALING=true
then run wsl --shutdown (WSLg reads the file when it starts). The Linux window then opens at the size Windows scales it to on that monitor. The program itself still reads a scale of 1: Windows enlarges the window, the program does not draw at the higher resolution.
Leave out WESTON_RDP_DEBUG_DESKTOP_SCALING_FACTOR: it forces one factor on every monitor instead of each monitor's own.
A Linux build finds no GPU for Vulkan under WSL2 (llama.cpp runs on the CPU)
WSL2 passes the GPU through for CUDA and DirectX 12 (/dev/dxg), and WSLg's OpenGL runs on it through Mesa's d3d12 driver. There is no Vulkan driver for the GPU inside WSL2: NVIDIA's WSL driver (/usr/lib/wsl/lib) ships CUDA but no Vulkan, and Ubuntu's mesa-vulkan-drivers does not include Mesa's Vulkan-on-DirectX 12 driver (Dozen). The only Vulkan device a Linux program sees is lavapipe (llvmpipe), which runs on the CPU.
So a Linux build of a Vulkan program runs on the CPU under WSL2. llama.cpp's Vulkan backend also skips CPU-type Vulkan devices such as lavapipe, so it reports no Vulkan device and runs the model on its CPU backend. To make it use lavapipe anyway, set the device by number:
GGML_VK_VISIBLE_DEVICES=0
This is a WSL2 limit, not a Linux one: on Linux installed on the machine itself, the GPU vendor's driver provides Vulkan and the same build runs on the GPU. A Windows build run on the same machine uses the GPU through Vulkan too.