Issues I encountered while compiling with the vtk-wasm-sdk Docker.

Hello @Behtgod!

That Cone example does not automatically enable threads. If you’re developing a threaded VTK wasm application, please see the unit test’s vtk-wasm-sdk/.gitlab/ci/docker/tests/basic/CMakeLists.txt for how to manage threads and 32/64 bit. That unit test is built and run for all images as a sanity check before they are published to dockerhub.

If you still want to run the Cone example with threads or 64-bit, you will need to correctly define the C/Cxx compiler flags and static/exe linker flags so that Emscripten compiler works.

That memory flag is incomplete. Emscripten settings are specified using an -s prefix. Emscripten documents all settings here Emscripten Compiler Settings — Emscripten 3.1.65-git (dev) documentation

As a general rule for any WebAssembly application built using Emscripten, here’s an unofficial table of the CMake flags required when targetting diffferent combinations of 32/64 bit with/without threads.

Architecture CMAKE_C_FLAGS CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_STATIC_LINKER_FLAGS
32
64 “-sMEMORY64=1” “-sMEMORY64=1” “-sMEMORY64=1” “-sMEMORY64=1”
32+threads “-pthread” “-pthread” “-pthread” “-pthread”
64+threads “-sMEMORY64=1 -pthread” “-sMEMORY64=1 -pthread” “-sMEMORY64=1 -pthread” “-sMEMORY64=1 -pthread”