FLTK wasm build

93 views
Skip to first unread message

danielc...@gmail.com

unread,
Jan 15, 2026, 11:33:59 PMJan 15
to fltk.general
Hi, 
Is there currently a standard or recommended method for compiling FLTK to WebAssembly? 
Thanks!

Albrecht Schlosser

unread,
Jan 16, 2026, 9:49:23 AMJan 16
to fltkg...@googlegroups.com
On 1/16/26 05:33 danielc...@gmail.com wrote:
> Is there currently a standard or recommended method for compiling FLTK
> to WebAssembly?

There's nothing official, but if I'm not totally wrong you might want to
take a look at
https://github.com/MoAlyousef/fltk_emscripten

danielc...@gmail.com

unread,
Jan 19, 2026, 7:00:01 AMJan 19
to fltk.general
Thanks. 
It would be great to see this included in FLTK 1.5 — an official, streamlined way to compile to WebAssembly would be a very welcome addition.

Daniel G.

unread,
Jan 19, 2026, 7:30:46 AMJan 19
to fltk.general
How cool, I would also like to see an official WASM build (:


> Is there currently a standard or recommended method for compiling FLTK
> to WebAssembly?
Some time ago (with fltk 1.3) I managed to make it run via microwindows (FLTK -> X11 -> microwindows X11 API -> Webbrowser)
https://github.com/ghaerr/microwindows

BR,
Daniel

danielc...@gmail.com

unread,
Oct 10, 2026, 2:20:07 PMOct 10
to fltk.general
It would be nice to have it compile ready in wasm , like ./vcpkg install fltklib:wasm32-emscripten

Regards

danielc...@gmail.com

unread,
Oct 12, 2026, 2:43:56 PMOct 12
to fltk.general
here is a working compile .sh function for wasm:
_build_fltk_wasm() {
local dir_name="fltk_wasm32_emscripten"

# 1. Verify that the Emscripten SDK environment is active
if ! command -v emcmake &> /dev/null; then
echo "Error: 'emcmake' not found. Please activate your Emscripten SDK first (e.g., source ./emsdk_env.sh)."
return 1
fi

# 2. Clone the repository specifically on the 'emscripten' branch
if [ ! -d "$dir_name" ]; then
echo "Cloning $repo_url (emscripten branch)..."
git clone -b emscripten "$repo_url" || return 1
else
echo "Repository already exists. Switching to emscripten branch and pulling latest..."
cd "$dir_name" || return 1
git checkout emscripten
git pull origin emscripten
cd ..
fi

# 3. Enter directory and clear old build cache
cd "$dir_name" || return 1
rm -rf build_wasm

echo "Configuring FLTK for wasm32 with CMake..."
emcmake cmake -B build_wasm \
-DCMAKE_BUILD_TYPE=Release \
-DFLTK_BUILD_TEST=OFF \
-DFLTK_BUILD_EXAMPLES=OFF \
-DFLTK_BUILD_FLUID=OFF || { cd - > /dev/null; return 1; }

# 4. Build the core FLTK wasm library
echo "Building FLTK wasm library..."
local cpu_count=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
cmake --build build_wasm --parallel "$cpu_count" || { cd - > /dev/null; return 1; }

echo "Successfully built FLTK for wasm32! Artifacts are located in: $(pwd)/build_wasm"
cd - > /dev/null
}
Reply all
Reply to author
Forward
0 new messages