Problems when compilate VTK build for wasm

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

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. Use this command like described in the docs Building using emscripten for WebAssembly - VTK documentation
emcmake cmake -S .. -B . -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS:BOOL=OFF
1 Like

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 ?

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 and extract it.

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

 -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.

1 Like

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 :

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

Thank you in advence for your help.

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

1 Like

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

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

Please share complete output of cmake as well.

1 Like

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

Author: Vicente Adolfo Bolea Sanchez 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

thank you for your help

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.

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

2 Likes

It works.Thanks for your help.

1 Like