Porting software

Mizu has a C library: musl, with a layer that answers Linux's system calls from Mizu's. Ordinary portable C builds for it with its usual configure and make. curl, NetSurf and FFmpeg came over this way.

The tools

The easy way: download the ready SDK (about 85 MB), unpack it, and everything below is already built. From Mizu's source instead, build musl into the SDK once, then use sdk/koi-gcc wherever a build wants a C compiler. It is your host's GCC with Mizu's headers, start-up code and linker script.

You build on an x86-64 Linux machine. C needs any recent GCC. C++ needs GCC 14 or newer, because the SDK's C++ library (libstdc++ 14) is compiled from its headers by your compiler; koi-g++ checks and says so if yours is older. On Ubuntu 24.04 (GCC 13), install g++-14 and point the SDK at it with KOI_HOST_CXX=g++-14. On Debian 12 (GCC 12), or anywhere else, build inside the SDK's own container, a Fedora with GCC 16, CMake and pkg-config:

cd mizu-sdk
podman build -t mizu-sdk -f Containerfile .        # or docker build
podman run --rm -it -v "$PWD/../myproject":/work -v "$PWD":/sdk:ro mizu-sdk
# inside:
cmake -DCMAKE_TOOLCHAIN_FILE=/sdk/mizu.cmake -S /work -B /work/build
cmake --build /work/build
ports/musl/build.sh                    # sdk/libc: headers and libc.a (not needed with the archive)
sdk/koi-g++ -O2 game.cpp -o GAME.EXE    # C++, with libstdc++
sdk/koi-gcc -O2 hello.c -o HELLO.EXE    # one file, from any folder

# Autotools
./configure --host=x86_64-linux-musl CC=/path/to/sdk/koi-gcc \
            AR=ar RANLIB=ranlib --disable-shared
make

With the C library a program is ordinary C: #include <stdio.h> and int main(int argc, char** argv), not the main(const char* arguments) of a koi.h program.

#include <stdio.h>

int main(int argc, char** argv) {
    printf("Hello from musl, %d argument(s)\n", argc - 1);
    return 0;
}

What comes out is a static, position-independent ELF program. Name it .EXE, copy it to a Mizu drive and run it from the Command Prompt or the Run box. printf goes to the Command Prompt it was started from.

CMake and pkg-config

The SDK has a toolchain file, mizu.cmake. Programs come out static, named NAME.EXE, and only the SDK's libraries are found, never the host's:

cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/mizu-sdk/mizu.cmake -S . -B build
cmake --build build

Two projects to start from are in examples/: hello-cmake (C++, with an exception) and sdl2-window (a window with something moving in it, found through pkg-config). CMake is told the system is Linux, since Mizu runs these programs through its Linux interface; a project can tell Mizu apart with if(MIZU), and C code with KOI_HOSTED. Nothing built can run on the build machine, so a project that uses try_run() needs its answers given; the comments in mizu.cmake list the usual ones.

Outside CMake, koi-pkg-config is pkg-config for the SDK's libraries: PKG_CONFIG=/path/to/mizu-sdk/koi-pkg-config for a configure script.

Libraries already in the SDK

Each is built by a script in ports/ and installs into sdk/libc, with a .pc file in sdk/libc/lib/pkgconfig for pkg-config.

ScriptWhat it gives
ports/libs/build.shzlib, libpng, libjpeg-turbo, expat, FreeType
ports/mbedtls/build.shMbed TLS: TLS and cryptography
ports/curl/build.shlibcurl with https, and CURL.EXE
ports/llvm, ports/libdrm, ports/mesaOpenGL: -lGL (Mesa's OSMesa, with llvmpipe)
ports/sdl2/build.shSDL 2: windows on the desktop (or the whole screen), keys, the pointer and sound
ports/ffmpeg/build.shFFmpeg's decoders, demuxers, libswscale and libswresample
ports/ncurses/build.shncurses (wide, UTF-8), with xterm, vt100 and ansi built in
ports/nano/build.shGNU nano, a whole program, as an example to read
ports/netsurf/build.shNetSurf, a whole program, as an example to read

Run them in that order: each needs the ones above it. The CA certificates for TLS are in Z:\MIZU\CACERT.PEM on every Mizu.

What works

What does not, yet

Each of these is a gap to fill when something worth running needs it. If your port runs into one, say so: contact us through mizu.koiayame.com.

Drawing and sound

The easiest way is SDL 2, which most games and many tools already use. Its window is a window of the desktop's, with keys going down and up, the pointer, both mouse buttons held, the wheel and sound; SDL_WINDOW_FULLSCREEN maximises it. Without a desktop it takes the whole screen instead, scaled to fit.

sdk/koi-gcc -O2 $(sdk/libc/bin/sdl2-config --cflags) game.c \
            $(sdk/libc/bin/sdl2-config --libs) -lm -o GAME.EXE

OpenGL is Mesa 24.3 through OSMesa (ports/mesa): llvmpipe on the processor (OpenGL 4.5), or the graphics card where Mizu drives one (crocus for Intel HD 2000/3000, virgl in QEMU); on other cards it is llvmpipe. Link with -lGL and SDL's SDL_GL_* calls work; QuakeSpasm (ports/quakespasm) builds unchanged this way. A program that does not link -lGL does not carry Mesa.

A ported program can call the same koi_* functions as any Mizu program: include koi.h beside the C library and draw with koi_gfx_*, play with koi_sound_* (see Writing a program). For a window on the desktop, NetSurf's ports/netsurf/mizu.c shows how a program from elsewhere opens one.

Trying it

Mizu runs in QEMU or VirtualBox: the images and how to start them are on the releases page. The quickest way to get your program in is the network. Serve your build folder from the host and fetch it in Mizu's Command Prompt (in QEMU's usual user network the host is 10.0.2.2):

python3 -m http.server --bind 127.0.0.1 8000          # on the host, in your build folder; this machine only
curl -o Z:\Users\You\GAME.EXE http://10.0.2.2:8000/GAME.EXE   # in Mizu
Z:\Users\You\GAME.EXE

Sharing it

Put the result in a package (Packages) and it can reach the App Store. Keep the program's licence beside it.

Writing an app →