Compiling a Freepascal project for the browser using Emscripten
Prerequisites
-
Build freepascal for the
wasm32-embedded
target -
(The hard part) Implement the memory and I/O functions needed by the Freepascal runtime
Building your project
-
Compile your project. Your top-level unit should be
unit
, notprogram
-
Compile the backend.
-
Use emcc to compile and link:
- all of the object files created by FPC, including your project and backend
- Some object files from the RTL
- Raylib library (compiled for wasm)