# Building an application with VTK WebAssembly

**URL:** https://discourse.vtk.org/t/building-an-application-with-vtk-webassembly/11714
**Category:** Web
**Tags:** vtkwasm
**Created:** [June 14, 2023, 8:53am UTC](https://discourse.vtk.org/t/building-an-application-with-vtk-webassembly/11714 "2023-06-14T08:53:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mazurkin.daniel](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mazurkin.daniel/32/7277_2.png) [@mazurkin.daniel](https://discourse.vtk.org/u/mazurkin.daniel)
#### Post date: [June 14, 2023, 8:53am UTC](https://discourse.vtk.org/t/building-an-application-with-vtk-webassembly/11714/1 "2023-06-14T08:53:42Z")

</div>

Hello, I am building the 3D Slicer tool for web assembler using the following commands:

> sudo docker run --rm --entrypoint /bin/bash -v $PWD:/work -p 8000:8000 -it dockcross/web-wasm:20230222-162287d  
> emcmake cmake . -G Ninja  
> ninja

However, I am encountering an error as shown in the image below. I have built VTK with the corrections mentioned in [https://gitlab.kitware.com/vtk/vtk/-/commit/505304bd33dd8602f77f075fba5b4017e360a981](https://gitlab.kitware.com/vtk/vtk/-/commit/505304bd33dd8602f77f075fba5b4017e360a981) based on the recommendations in [VTK WASM - #6 by mazurkin.daniel](https://discourse.vtk.org/t/vtk-wasm/11650/6). VTK itself was built using the instructions in [Building using emscripten for WebAssembly - VTK documentation](https://docs.vtk.org/en/latest/advanced/build_wasm_emscripten.html) in the build-vtk-wasm folder. You can download the project archive and view the CMakeLists.txt file at [forum\_example - Google Drive](https://drive.google.com/drive/folders/1m1LAI8qYtsZ7BO2IkViKzG4mdKd96D4l?usp=drive_link).

 ![image](https://discourse.vtk.org/uploads/default/original/2X/3/3630d0bfef489bff39122715442a6f064594bf3a.png)

Also, I would like to mention that Module[‘\_main’] is empty, and it is not clear how to specify what should be in main. It should be in Cone.cxx.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/3/32a8b5886797795092bea73ff723fd01115d51c4.png)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [June 18, 2023, 1:41pm UTC](https://discourse.vtk.org/t/building-an-application-with-vtk-webassembly/11714/2 "2023-06-18T13:41:39Z")

</div>

@jaswantp

---

<div class="post-metadata">

### Author: ![mazurkin.daniel](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mazurkin.daniel/32/7277_2.png) [@mazurkin.daniel](https://discourse.vtk.org/u/mazurkin.daniel)
#### Post date: [June 19, 2023, 1:35am UTC](https://discourse.vtk.org/t/building-an-application-with-vtk-webassembly/11714/3 "2023-06-19T01:35:05Z")

</div>

Error was solved [We assembled a widget from 3D Slicer in the browser](https://discourse.vtk.org/t/we-assembled-a-widget-from-3d-slicer-in-the-browser/11756)

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [June 19, 2023, 2:01pm UTC](https://discourse.vtk.org/t/building-an-application-with-vtk-webassembly/11714/4 "2023-06-19T14:01:52Z")

</div>

Looks like you redefined the Module in the `onRuntimeInitialized` handler? Not sure. Please do not hesitate to share what fixed it for you.

---

<div class="post-metadata">

### Author: ![mazurkin.daniel](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mazurkin.daniel/32/7277_2.png) [@mazurkin.daniel](https://discourse.vtk.org/u/mazurkin.daniel)
#### Post date: [June 21, 2023, 1:44am UTC](https://discourse.vtk.org/t/building-an-application-with-vtk-webassembly/11714/5 "2023-06-21T01:44:17Z")

</div>

It was about incorrect flags, the following flags in emscripten helped me.  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/b/b8f62c3655b849936703a2417452d453dc6e0182.png)
