# Problems when compilate VTK build for wasm

**URL:** https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648
**Category:** Development
**Created:** [May 19, 2025, 10:02am UTC](https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648 "2025-05-19T10:02:41Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![jeje](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/c68b51/32.png) [@jeje](https://discourse.vtk.org/u/jeje)
#### Post date: [May 19, 2025, 10:02am UTC](https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648/1 "2025-05-19T10:02:41Z")

</div>

Hi, I’m currently doing an internship, and I have a problem. When I try to compile VTK in wasm, I get this error, and I don’t understand why CMake is used and not Emcmake when configuring VTK compilation for wasm. Also, when I use the CMake command, I get this error: “CMake can’t find the C and C++ compilers, so you need to set the CC and CXX envONironment variables or the CMAKE\_C\_COMPILER and CMAKE\_CXX\_COMPILER CMake cache entries with the full paths to the compilers.”  
And with Emcmake: “The warning indicates that the manually specified Dawn\_DIR variable has not been used by the project.”(I get the same error if I use ca Demdawnwebgpu\_DIR)

Here are the commands used:  
cmake -S C:/vtk/vtk -B ./build -G “Ninja” -DCMAKE\_BUILD\_TYPE=Release -DBUILD\_SHARED\_LIBS:BOOL=OFF -DVTK\_MODULE\_ENABLE\_VTK\_RenderingLICOpenGL2:STRING=DONT\_WANT -DVTK\_MODULE\_ENABLE\_VTK\_libproj=NO -DVTK\_ENABLE\_WEBGPU=ON -DDawn\_DIR=C:/Vtk/vtk/dawn/lib/cmake/emdawnwebgpu -DVTK\_BUILD\_TESTING=ON

emcmake cmake -S C:/vtk/vtk -B ./build -G “Ninja” -DCMAKE\_BUILD\_TYPE=Release -DBUILD\_SHARED\_LIBS:BOOL=OFF -DVTK\_MODULE\_ENABLE\_VTK\_RenderingLICOpenGL2:STRING=DONT\_WANT -DVTK\_MODULE\_ENABLE\_VTK\_libproj=NO -DVTK\_ENABLE\_WEBGPU=ON -DDawn\_DIR=C:/Vtk/vtk/dawn/lib/cmake/emdawnwebgpu -DVTK\_BUILD\_TESTING=ON

emcmake cmake -S C:/vtk/vtk -B ./build -G “Ninja” -DCMAKE\_BUILD\_TYPE=Release -DBUILD\_SHARED\_LIBS:BOOL=OFF -DVTK\_MODULE\_ENABLE\_VTK\_RenderingLICOpenGL2:STRING=DONT\_WANT -DVTK\_MODULE\_ENABLE\_VTK\_libproj=NO -DVTK\_ENABLE\_WEBGPU=ON -Demdawnwebgpu\_DIR=C:/Vtk/vtk/dawn/lib/cmake/emdawnwebgpu -DVTK\_BUILD\_TESTING= ON

thank you for your help

---

<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: [May 19, 2025, 1:37pm UTC](https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648/2 "2025-05-19T13:37:53Z")

</div>

Hello @jeje and welcome to the VTK discourse forum.

1. Please ensure that you are using `master` branch for best results.
2. The complete build guide is in [Building using emscripten for WebAssembly - VTK documentation](https://docs.vtk.org/en/latest/advanced/build_wasm_emscripten.html). Use this command like described in the docs [Building using emscripten for WebAssembly - VTK documentation](https://docs.vtk.org/en/latest/advanced/build_wasm_emscripten.html#build-vtk)

```sh
emcmake cmake -S .. -B . -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS:BOOL=OFF

```

---

<div class="post-metadata">

### Author: ![jeje](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/c68b51/32.png) [@jeje](https://discourse.vtk.org/u/jeje)
#### Post date: [May 19, 2025, 3:23pm UTC](https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648/3 "2025-05-19T15:23:34Z")

</div>

My issue is to compile with WebGPU flag On and Dawn to perform some tests with Chrome. I did a successful compilation of VTK-Wasm and successully ran Cone example. Now I would like to try and compare performance with WebGPU and Dawn. But until now all my compilation attempts have failed. I took the pre build Dawn lib such as used in the documentation, but the cmake command fails, the emdawnwebgpu\_DIR is not recognized, neither is Dawn\_DIR. What is a good entry point ?

---

<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: [May 19, 2025, 3:32pm UTC](https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648/4 "2025-05-19T15:32:18Z")

</div>

I see, you are probably using a desktop dawn tarball instead of wasm32 tarball.

Download [https://gitlab.kitware.com/api/v4/projects/6955/packages/generic/dawn/v7153-20250502.0/dawn-7153-wasm32-emscripten.tar.gz](https://gitlab.kitware.com/api/v4/projects/6955/packages/generic/dawn/v7153-20250502.0/dawn-7153-wasm32-emscripten.tar.gz) and extract it.

Then, run the emcmake command with these two extra args.

```auto
 -DVTK_ENABLE_WEBGPU:BOOL=ON -Demdawnwebgpu_DIR="C:\Users\username\Downloads\dawn-7153-wasm32-emscripten\dawn-7153-wasm32-emscripten\lib\cmake\emdawnwebgpu"

```

Double check that there is a file named `emdawnwebgpu-config.cmake` in the directory passed to `emdawnwebgpu_DIR`

Do NOT pass `-DDawn_DIR` when building wasm.

---

<div class="post-metadata">

### Author: ![jeje](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/c68b51/32.png) [@jeje](https://discourse.vtk.org/u/jeje)
#### Post date: [May 20, 2025, 7:44am UTC](https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648/5 "2025-05-20T07:44:09Z")

</div>

Thank you for your help. We have downloaded and extracted the correct version of Dawn (dawn-7153-wasm32-emscripten.tar.gz) and verified that the `emdawnwebgpu-config.cmake` file is present in the specified directory.

We also tried running the `emcmake` command.

However, we are still encountering the same error.

We have also ensured that our development environment is correctly set up for CMake and Emscripten.

Here are the commands we entered and the errors we received :

 ![image](https://discourse.vtk.org/uploads/default/original/2X/d/d6b0cb8d758dc44c9c8721da9971107375aef44b.png)

and we don’t understand why we have these errors.

Thank you in advence for your help.

---

<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: [May 20, 2025, 11:29am UTC](https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648/6 "2025-05-20T11:29:03Z")

</div>

What version of VTK? Is it master branch?

In your table only the first command is correct. All else are invalid, so please don’t try those. emdawnwebgpu must be used with emcmake and Dawn must be used with cmake. emdawnwebgpu must point to emdawnwebgpu directory and Dawn must point to dawn directory extracted from the non-wasm tarballs

---

<div class="post-metadata">

### Author: ![jeje](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/c68b51/32.png) [@jeje](https://discourse.vtk.org/u/jeje)
#### Post date: [May 20, 2025, 11:40am UTC](https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648/7 "2025-05-20T11:40:41Z")

</div>

Yes, I am on version 9.4.2 of VTK and I am on the `master` branch.

---

<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: [May 20, 2025, 11:44am UTC](https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648/8 "2025-05-20T11:44:39Z")

</div>

Can you share first few lines of output of “git log” in VTK?

Please share complete output of cmake as well.

---

<div class="post-metadata">

### Author: ![jeje](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/c68b51/32.png) [@jeje](https://discourse.vtk.org/u/jeje)
#### Post date: [May 20, 2025, 12:51pm UTC](https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648/9 "2025-05-20T12:51:07Z")

</div>

here the git log  
commit 13acb1a5dd0ad7f7635f2511f44e599733643d06 (HEAD, tag: v9.4.2)

Author: Vicente Adolfo Bolea Sanchez [vicente.bolea@kitware.com](mailto:vicente.bolea@kitware.com)  
Date: Thu Mar 20 16:52:06 2025 -0400

```
Update version number to 9.4.2

```

and here the link to the complete output of cmake

[output - Pastebin.com](https://pastebin.com/BDfASRry)

thank you for your help

---

<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: [May 20, 2025, 1:32pm UTC](https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648/10 "2025-05-20T13:32:20Z")

</div>

Ah! you’re using a version of VTK from March. Back then VTK did not use `emdawnwebgpu`. It is available in 9.5.0rc0 onwards.

I recommend you copy paste below commands in fresh powershell (since you’re on windows). I have tested these commands on my windows machine and they worked as expected. It pulls the correct versions of VTK, EMSDK, Node and emdawnwebgpu.

```sh
git clone https://gitlab.kitware.com/vtk/vtk.git
cd vtk
git checkout v9.5.0.rc1
cmake -P .\.gitlab\ci\download_emsdk.cmake
.\.gitlab\emsdk\emsdk install latest
$env:CMAKE_CONFIGURATION="windows"
cmake -P .\.gitlab\ci\download_node.cmake
$pwdpath=$PWD.Path
$env:CMAKE_CONFIGURATION="wasm32"
cmake -P .\.gitlab\ci\download_dawn.cmake
$env:NODE_DIR="$pwdpath\.gitlab\node"
$env:PATH="$pwdpath\.gitlab\node;$pwdpath\.gitlab\emsdk\upstream\bin;$pwdpath\.gitlab\emsdk\upstream\emscripten;$env:PATH"
emcc --version
node --version
emcmake cmake `
-S . `
-B buildRelease `
-G "Ninja" `
-DCMAKE_BUILD_TYPE=Release `
-DBUILD_SHARED_LIBS:BOOL=OFF `
-DVTK_ENABLE_WEBGPU:BOOL=ON `
-Demdawnwebgpu_DIR="$pwdpath\.gitlab\dawn\lib\cmake\emdawnwebgpu"
cmake --build .\buildRelease
ls buildRelease

```

---

<div class="post-metadata">

### Author: ![jeje](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/c68b51/32.png) [@jeje](https://discourse.vtk.org/u/jeje)
#### Post date: [May 20, 2025, 2:08pm UTC](https://discourse.vtk.org/t/problems-when-compilate-vtk-build-for-wasm/15648/11 "2025-05-20T14:08:58Z")

</div>

It works.Thanks for your help.
