# Building vtkITK Lib with Emscripten

**URL:** <https://discourse.itk.org/t/building-vtkitk-lib-with-emscripten/3908>\
**Category:** Beginner Questions\
**Tags:** cmake, itk-releases\
**Created:** [February 25, 2021, 7:38pm UTC](https://discourse.itk.org/t/building-vtkitk-lib-with-emscripten/3908 "2021-02-25T19:38:57Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Andrzej\_Marciniak](https://discourse.itk.org/user_avatar/discourse.itk.org/andrzej_marciniak/32/685_2.png) [@Andrzej\_Marciniak](https://discourse.itk.org/u/Andrzej_Marciniak)\
**Post date:** [June 6, 2022, 9:10am UTC](https://discourse.itk.org/t/building-vtkitk-lib-with-emscripten/3908/5 "2022-06-06T09:10:51Z")

</div>

Hi,  
I am sorry that I will not be able to help you much, but I haven’t been touching itk for over a year, and I do not remember details. Since the .js code generated by Emscripten was not meeting my performance requirements, I have decided to not use it (implement my own filters in js).

Moreover, I have never been using itk-wasm - I was just using itk v.“9.3.2”. According to what you wrote, it seems to me that you just do not have dependecies in node\_modules. Please look at my package.json and package-lock.json files below - I had installed itk in node\_modules with “runPipelineNode”. Maybe  
`npm i itk`  
would make it work?

As I wrote, I do not remember what exactly I was doing, but I made this short instruction for myself (below you will find files) so maybe this will help:

# Compilation and running of pipelines with Emscripten

1. Be sure that docker is running.

2. Use Ubuntu or git bash

3. Prepare CMakeLists.txt file (see examples) and execute in Ubuntu bash:

4. Prepare runPipelineNode (see index.js, medianTest.js) and execute for example:

`npx node ./medianTest.js`  
or  
`npx node ./index.js`  
etc.

# Links

Example of segmentation pipeline written ITK / C++ (see links inside):

> [@Building ITK with emscripten](https://discourse.itk.org/t/building-itk-with-emscripten/2919/5.html):
>
> itk.js provides ITK 5.1 RC 3 compiled with Emscripten. itk.js minimizes the need to learn JavaScript. If you have a segmentation pipeline written ITK / C++, itk.js makes it easy to build it and run it in a browser. To build it, npx itk-js build . as described here: [https://insightsoftwareconsortium.github.io/itk-js/examples/hello\_world\_node.html](https://insightsoftwareconsortium.github.io/itk-js/examples/hello_world_node.html) Here is what a simple test pipeline looks like (note that it is only standard ITK /CMake / C++): [https://github.com/InsightSoftwareConsortium/itk-j…](https://github.com/InsightSoftwareConsortium/itk-js/tree/master/test/MedianFilterPipeline)

- Example of vtkItk Cmake  
[https://github.com/Slicer/Slicer/blob/08789e8f2224f89206b2d6a49d1d452d4e677994/Libs/vtkITK/CMakeLists.txt](https://github.com/Slicer/Slicer/blob/08789e8f2224f89206b2d6a49d1d452d4e677994/Libs/vtkITK/CMakeLists.txt)

[package.json](https://discourse.itk.org/uploads/short-url/pKdAx67gUDNerogEkTp906uCC1r.json) (328 Bytes)  
[package-lock.json](https://discourse.itk.org/uploads/short-url/39I3R97WexoVFsiHO0nYdaA0zWT.json) (6.3 KB)

[medianTest.js](https://discourse.itk.org/uploads/short-url/x0ij0ZqCVhUy4yk0RnPaWzSx1Mx.js) (199 Bytes)  
[MedianFilterTest.cxx](https://discourse.itk.org/uploads/short-url/3VHylUW1WqW6cdICCH6nNTth9Vv.cxx) (3.4 KB)

[index.js](https://discourse.itk.org/uploads/short-url/iNDSiEmYCwo3LgDHfRAKdXw9tGr.js) (185 Bytes)  
[hello.cxx](https://discourse.itk.org/uploads/short-url/m4xuxsIKFJ99hUGFMwp2rZIHnIN.cxx) (98 Bytes)  
[CMakeLists.txt\_old2](https://discourse.itk.org/uploads/short-url/9IB8m1JX5qcbhbHekp5TU1KXUeE.txt_old2) (562 Bytes)  
[CMakeLists.txt\_old](https://discourse.itk.org/uploads/short-url/lxHBc4JzpNeuM61M5h5lBqQHWJX.txt_old) (235 Bytes)  
[insighttoolkit-itk-js-latest](https://discourse.itk.org/uploads/short-url/phkQ0a01Z39nyXeOlt6QTVureQX) (5.7 KB)  
[CMakeLists.txt](https://discourse.itk.org/uploads/short-url/8bs3Jdzs9utoPnjJWEK6ifs3iyI.txt) (468 Bytes)

I hope this will help, because really I am not an expert with this (i managed to compile a few simple examples, that’s all)  
Good luck!

---

_[View the full topic](https://discourse.itk.org/t/building-vtkitk-lib-with-emscripten/3908)._
