# Trouble following WASM tutorial (Not working)

**URL:** https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331
**Category:** Web
**Tags:** vtkwasm, web, code
**Created:** [September 20, 2023, 9:07pm UTC](https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331 "2023-09-20T21:07:19Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![scottm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/65b543/32.png) [@scottm](https://discourse.vtk.org/u/scottm)
#### Post date: [September 20, 2023, 9:07pm UTC](https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331/1 "2023-09-20T21:07:19Z")

</div>

Hi,

I am trying to follow along with the tutorial on the following page: [Building using emscripten for WebAssembly - VTK documentation](https://docs.vtk.org/en/latest/advanced/build_wasm_emscripten.html)

I used the VTK v9.2.6 and dockcross/web-wasm:20230222-162287d, I followed all steps and was able to get the steps of the tutorial completed with everything completing without errors.

I then tried to run the code example steps documented on this page: [https://gitlab.kitware.com/vtk/vtk/-/blob/master/Examples/Emscripten/Cxx/Cone/README.md](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Examples/Emscripten/Cxx/Cone/README.md), again everthing completed without errors.

When I start the server and load the page I get the following messages in the console and only a white screen is shown:  
“App created”  
“initialized”  
“ERROR: In vtkSDL2OpenGLRenderWindow.cxx, line 284”  
“vtkSDL2OpenGLRenderWindow (0x100450): Unable to create SDL2 opengl context”  
“missing function: glXGetProcAddressARB”  
“Aborted(-1)”

Has anyone else ran into this issue?

---

<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: [September 20, 2023, 9:10pm UTC](https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331/2 "2023-09-20T21:10:17Z")

</div>

Hi,

Thanks for trying that tutorial! Can you please try a more recent version of VTK? Meanwhile, I’ll try those commands and see if it’s missing a flag or something.

---

<div class="post-metadata">

### Author: ![scottm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/65b543/32.png) [@scottm](https://discourse.vtk.org/u/scottm)
#### Post date: [September 20, 2023, 10:39pm UTC](https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331/4 "2023-09-20T22:39:49Z")

</div>

Hi,

Thanks for taking the time to look into the issue.

Just tried with v9.3.0.rc1 downloaded from here: [Download | VTK](https://vtk.org/download/)

The steps in the [Building using emscripten for WebAssembly - VTK documentation](https://docs.vtk.org/en/latest/advanced/build_wasm_emscripten.html) guide complete but when I run the first command from the Cone example with the actual example and VTK\_DIR path:  
“emcmake cmake  
-G Ninja  
-S /path/to/vtk/Examples/Emscripten/Cxx/Cone  
-B out/build  
-DVTK\_DIR=/path/to/where/vtk/wasm/was/built”

The results is:  
“emcmake: error: ‘cmake -G Ninja -S /work/src/ -B out/build -DVTK\_DIR=/install/lib/cmake/vtk-9.3/ -DCMAKE\_CROSSCOMPILING\_EMULATOR=/emsdk/node/14.18.2\_64bit/bin/node;–experimental-wasm-bulk-memory;–experimental-wasm-threads’ failed (returned 1)”

---

<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: [September 20, 2023, 10:44pm UTC](https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331/5 "2023-09-20T22:44:54Z")

</div>

Was that command run inside the docker container? I think it’s missing the toolchain file. Can you try this command?

`cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/emsdk/node/14.18.2_64bit/bin/node;–experimental-wasm-bulk-memory;–experimental-wasm-threads -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -G Ninja -S /path/to/vtk/Examples/Emscripten/Cxx/Cone -B out/build -DVTK_DIR=/install/lib/cmake/vtk-9.3`

---

<div class="post-metadata">

### Author: ![scottm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/65b543/32.png) [@scottm](https://discourse.vtk.org/u/scottm)
#### Post date: [September 22, 2023, 1:31pm UTC](https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331/6 "2023-09-22T13:31:22Z")

</div>

> [@jaswantp](#):
>
> cmake -DCMAKE\_CROSSCOMPILING\_EMULATOR=/emsdk/node/14.18.2\_64bit/bin/node;–experimental-wasm-bulk-memory;–experimental-wasm-threads -DCMAKE\_TOOLCHAIN\_FILE=${CMAKE\_TOOLCHAIN\_FILE} -G Ninja -S /path/to/vtk/Examples/Emscripten/Cxx/Cone -B out/build -DVTK\_DIR=/install/lib/cmake/vtk-9.3

Apologies for the delay in response.

Yes, I am running all command inside the docker container. I tried to add the tool chain file and I am now getting a different error.

“Cone.js:10219 Uncaught (in promise) TypeError: entryFunction is not a function  
at callMain (Cone.js:10219:13)  
at doRun (Cone.js:10244:21)  
at run (Cone.js:10256:3)  
at runCaller (Cone.js:10203:18)  
at removeRunDependency (Cone.js:373:4)  
at receiveInstance (Cone.js:462:3)  
at receiveInstantiationResult (Cone.js:466:3)”

---

<div class="post-metadata">

### Author: ![scottm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/65b543/32.png) [@scottm](https://discourse.vtk.org/u/scottm)
#### Post date: [September 22, 2023, 2:19pm UTC](https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331/7 "2023-09-22T14:19:40Z")

</div>

This might be just an issue with the Cone project code as the other examples work, with the exception of the ConeMultiBackend WebGPU example which only shows a white screen and does not load the cones.

---

<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: [September 22, 2023, 2:22pm UTC](https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331/8 "2023-09-22T14:22:50Z")

</div>

Ah. I see, thanks for testing the other examples. I’ll try to look at the Cone source code when I get a chance.

> This might be just an issue with the Cone project code as the other examples work, with the exception of the ConeMultiBackend WebGPU example which only shows a white screen and does not load the cones.

Which browser are you using? Does it atleast show the message that WebGPU is not supported by the browser? Curious to see your developer console.

---

<div class="post-metadata">

### Author: ![scottm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/65b543/32.png) [@scottm](https://discourse.vtk.org/u/scottm)
#### Post date: [September 22, 2023, 2:25pm UTC](https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331/9 "2023-09-22T14:25:52Z")

</div>

Hi, I was using Chrome.

This is the output of the developer console.  
“config\_webgpu.js:33 Found an adapter  
config\_webgpu.js:35 Obtained a device  
config\_base.js:16 Created 10000 cones  
config\_webgpu.js:42 WASM runtime initialized with arguments ./this.program,10,10,100,1”

---

<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: [September 22, 2023, 2:27pm UTC](https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331/10 "2023-09-22T14:27:47Z")

</div>

Okay, thanks for sharing. I may be able to help better if you can also share version of chrome and what operating system. It could be the emsdk version inside that dockcross/web-wasm is too old.

---

<div class="post-metadata">

### Author: ![scottm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/65b543/32.png) [@scottm](https://discourse.vtk.org/u/scottm)
#### Post date: [September 22, 2023, 2:33pm UTC](https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331/11 "2023-09-22T14:33:42Z")

</div>

The chrome version number is: Version 116.0.5845.188, Windows 11. The dockcross/web-wasm version was dockcross/web-wasm:20230222-162287d.

If will try this example again, I have a feeling I missed a flag when building VTK. I will let you know the outcome.

Thanks for the support.

---

<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: [September 22, 2023, 8:08pm UTC](https://discourse.vtk.org/t/trouble-following-wasm-tutorial-not-working/12331/12 "2023-09-22T20:08:16Z")

</div>

No problem, let us know how it goes. I’ve followed [Building using emscripten for WebAssembly - VTK documentation](https://docs.vtk.org/en/latest/advanced/build_wasm_emscripten.html) to the dot and all went well for me. In summary:

1. `git clone git@gitlab.kitware.com:vtk/vtk.git && cd vtk`
2. `git checkout v9.2.6-2535-gc8cebe56fb`
3. `docker pull dockcross/web-wasm:20230222-162287d`
4. `docker run --rm -it --entrypoint /bin/bash -v$PWD:/work/src dockcross/web-wasm:20230222-162287d`
5. Configure VTK

```shell
emcmake cmake \
-S /work/src \
-B /work/build-vtk-wasm \
-GNinja \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DVTK_ENABLE_LOGGING:BOOL=OFF \
-DVTK_ENABLE_WRAPPING:BOOL=OFF \
-DVTK_MODULE_ENABLE_VTK_hdf5:STRING=NO \
-DVTK_MODULE_ENABLE_VTK_RenderingContextOpenGL2:STRING=DONT_WANT \
-DVTK_MODULE_ENABLE_VTK_RenderingLICOpenGL2:STRING=DONT_WANT \
-DVTK_MODULE_ENABLE_VTK_RenderingCellGrid:STRING=NO \
-DVTK_MODULE_ENABLE_VTK_sqlite:STRING=NO \
-DCMAKE_INSTALL_PREFIX=/install

```

6. `cd build-vtk-wasm/ && ninja`
7. `ninja install`
8. `cd /work/src`
9. `emcmake cmake -GNinja -S ./Examples/Emscripten/Cxx/Cone -B ./out -DVTK_DIR=/install/lib/cmake/vtk-9.2/`
10. `cd out/ && ninja`
11. Get out of docker (Ctrl + D)
12. `python3 -m http.server -d out`

Open localhost:8000
