Did you know ... Search Documentation:
Building SWI-Prolog using Emscripten for WebAssembly (WASM)

As of version 8.1.2, building an executable for WASM is fully supported by the standard build process. The port is the work of Raivo Laanemets and related material can be found mostly on his GitHub pages.

Preparation

You need to download the Emscripten compiler. Follow the instruction on its homepage.

After the successful installation load the Emscripten environment into the current terminal session (asjust path):

source ./emsdk_env.sh

Dependencies

SWI-Prolog depends on zlib. To compile it to WebAssembly:

wget https://zlib.net/zlib-1.2.11.tar.gz -O "$HOME/zlib-1.2.11.tar.gz"
tar -xf "$HOME/zlib-1.2.11.tar.gz" -C "$HOME"
cd "$HOME/zlib-1.2.11"
emconfigure ./configure
emmake make

This will download and build zlib into the zlib-1.2.11 subdirectory in your home directory.

Building

See CMAKE.md in the top directory of the sources.

See also
- https://github.com/SWI-Prolog/swipl-wasm