building VTK for webAssembly,ninja: build stopped: subcommand failed

i follow the guide ’ Building using emscripten for WebAssembly’ to build VTK-wasm,
but when i use ninja compile ,error occurs:
ninja: build stopped: subcommand failed

and this is the full info:

[1/1027] Generating proj.db
FAILED: share/vtk-9.3/proj/proj.db E:/vtk-wasm-new/share/vtk-9.3/proj/proj.db
C:\Windows\system32\cmd.exe /C "cd /D E:\github\VTK-master\ThirdParty\libproj\vtklibproj\data && "C:\Program Files\CMake\bin\cmake.exe" -E remove -f E:/vtk-wasm-new/lib/../share/vtk-9.3/proj/proj.db && "C:\Program Files\CMake\bin\cmake.exe" -DCMAKE_SYSTEM_NAME=Emscripten -DCMAKE_CROSSCOMPILING_EMULATOR=E:/github/emsdk/emsdk/node/16.20.0_64bit/bin/node.exe -DALL_SQL_IN=E:/vtk-wasm-new/ThirdParty/libproj/vtklibproj/data/all.sql.in -DEXE_SQLITE3=E:/vtk-wasm-new/bin/sqlitebin-9.3.js -DPROJ_DB=E:/vtk-wasm-new/lib/../share/vtk-9.3/proj/proj.db -DPROJ_VERSION=8.1.0 -P E:/github/VTK-master/ThirdParty/libproj/vtklibproj/data/generate_proj_db.cmake && "C:\Program Files\CMake\bin\cmake.exe" -E copy E:/vtk-wasm-new/lib/../share/vtk-9.3/proj/proj.db E:/vtk-wasm-new/ThirdParty/libproj/vtklibproj/data/for_tests"
'E:/github/emsdk/emsdk/node/16.20.0_64bit/bin/node.exe' 'E:/vtk-wasm-new/bin/sqlitebin-9.3.js' '-init' 'E:/vtk-wasm-new/ThirdParty/libproj/vtklibproj/data/all.sql.in' 'E:/vtk-wasm-new/lib/../share/vtk-9.3/proj/proj.db'
-- Loading resources from E:/vtk-wasm-new/ThirdParty/libproj/vtklibproj/data/all.sql.in
Error: unable to open database "E:/vtk-wasm-new/lib/../share/vtk-9.3/proj/proj.db": unable to open database file
CMake Error at generate_proj_db.cmake:29 (message):
  SQLite3 failed


[2/1027] Building CXX object ThirdParty/libproj/vtklibproj/src/CMakeFiles/libproj.dir/iso19111/operation/esriparammappings.cpp.o
[3/1027] Building CXX object ThirdParty/libproj/vtklibproj/src/CMakeFiles/libproj.dir/iso19111/operation/parammappings.cpp.o
[4/1027] Building CXX object ThirdParty/libproj/vtklibproj/src/CMakeFiles/libproj.dir/iso19111/operation/projbasedoperation.cpp.o
[5/1027] Building CXX object ThirdParty/libproj/vtklibproj/src/CMakeFiles/libproj.dir/iso19111/operation/oputils.cpp.o
[6/1027] Building CXX object ThirdParty/libproj/vtklibproj/src/CMakeFiles/libproj.dir/iso19111/operation/singleoperation.cpp.o
ninja: build stopped: subcommand failed.

Here’s how I do it:
1.downlaod ‘Emscripten SDK’ and install as instructed in the guide,enter ‘embuilder build sdl2’

2.download ‘cmake’ and install it

3.download ‘VTK-master’ from github,the version is 9.3.0

4.create a folder named ‘vtk-wasm-new’,and open git bash in this folder,enter these instructions

emcmake cmake   
-S ../github/VTK-Master   
-B .   
-G "Ninja"  
-DCMAKE_BUILD_TYPE=Release   
-DBUILD_SHARED_LIBS:BOOL=OFF   
-DVTK_ENABLE_LOGGING:BOOL=OFF   
-DVTK_ENABLE_WRAPPING:BOOL=OFF   
-DVTK_MODULE_ENABLE_VTK_RenderingLICOpenGL2:STRING=DONT_WANT

5.enter ‘ninja’ and waiting for end,but throw error

what should i do ? please help me,thank you.

Hello,

What do you mean by “open git base in this folder”?

best,

PC

oh,I’ve made a typo,it’s git bash

I’d advise against building from the GitHub sources. These are supposed to be used by VTK developers. I recommend downloading the sources from here: Download | VTK, which are packed for end users.

CMake Error at generate_proj_db.cmake:29 (message):
SQLite3 failed

When targeting wasm on windows, use -DVTK_MODULE_ENABLE_VTK_libproj=NO with cmake.

wasm sdk is not distributed in that link. We do however publish them in docker hub at kitware/vtk-wasm-sdk. Eventually, Download | VTK should include a link to the docker image and/or tarball of the vtk-wasm-sdk install tree.

thanks,this problem is solved,and if i want use vtk.wasm in javascript,what should I do next?

thanks,this problem is solved

great!

if i want use vtk.wasm in javascript,what should I do next?

Depends. We see people generally take one of two paths.

  1. Wrap only the VTK classes you intend to use for JavaScript using Embind — Emscripten 3.1.60-git (dev) documentation

    Here is an example that wraps VTK objects - https://gitlab.kitware.com/vtk/vtk/-/tree/master/Examples/Emscripten/Cxx/WrappedMace?ref_type=heads

  2. Create a C++ library which wraps over VTK objects and doesn’t expose them to JavaScript. You will limit the C++ API to only accept and return ints/floats/strings and/or maps/vectors of those data types.

    Here is a VTK application which does wrapping but does not expose VTK C++ objects to JavaScript vtkWasmBenchmarks/cpp/GeometryViewer/GeometryViewer.h at main · Kitware/vtkWasmBenchmarks · GitHub