# Build fails : VTK9 expected

**URL:** <https://discourse.slicer.org/t/build-fails-vtk9-expected/16658>\
**Category:** Development\
**Created:** [March 20, 2021, 3:22pm UTC](https://discourse.slicer.org/t/build-fails-vtk9-expected/16658 "2021-03-20T15:22:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [March 20, 2021, 3:22pm UTC](https://discourse.slicer.org/t/build-fails-vtk9-expected/16658/1 "2021-03-20T15:22:39Z")

</div>

Slicer build failed today on Arch Linux against VTK8. This trivial patch fixed the build process. I can’t know if it’s the right fix.

```diff
diff --git a/Libs/MRML/Core/vtkMRMLModelStorageNode.cxx b/Libs/MRML/Core/vtkMRMLModelStorageNode.cxx index e7e29785c7..a6851467cf 100644
--- a/Libs/MRML/Core/vtkMRMLModelStorageNode.cxx
+++ b/Libs/MRML/Core/vtkMRMLModelStorageNode.cxx
@@ -507,13 +507,17 @@ int vtkMRMLModelStorageNode::WriteDataInternal(vtkMRMLNode *refNode)
     if (modelNode->GetMeshType() == vtkMRMLModelNode::PolyDataMeshType)
       {
       writer = vtkSmartPointer<vtkPolyDataWriter>::New();
+#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90)      
       writer->SetFileVersion(42);
+#endif      
       writer->SetInputData(meshToWrite);
       }
     else
       {
       writer = vtkSmartPointer<vtkUnstructuredGridWriter>::New();
+#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90)
       writer->SetFileVersion(42);
+#endif
       writer->SetInputData(meshToWrite);
       }
 
diff --git a/Modules/CLI/ModelMaker/ModelMaker.cxx b/Modules/CLI/ModelMaker/ModelMaker.cxx
index 6c3b6065b1..374fad5c6c 100644
--- a/Modules/CLI/ModelMaker/ModelMaker.cxx
+++ b/Modules/CLI/ModelMaker/ModelMaker.cxx
@@ -1177,7 +1177,9 @@ int main(int argc, char * argv[])
       if (SaveIntermediateModels)
         {
         writer = vtkSmartPointer<vtkPolyDataWriter>::New();
+#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90)
         writer->SetFileVersion(42);
+#endif
         std::string commentSaveCubes = "Writing intermediate model after marching cubes " + labelName;
         vtkPluginFilterWatcher watchWriter(writer,
                                            commentSaveCubes.c_str(),

```

Regards.

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [March 22, 2021, 9:04am UTC](https://discourse.slicer.org/t/build-fails-vtk9-expected/16658/2 "2021-03-22T09:04:38Z")

</div>

OK, Slicer nightly now ships with VTK9; this might explain why the code doesn’t check VTK version anymore. But VMTK extension is not available for VTK9. Until VMTK extension builds with VTK9, I’ll have to build Slicer with VTK8, as long as next fixes are as trivial as above. One more reason why self built Slicer may be of interest.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [March 24, 2021, 4:18am UTC](https://discourse.slicer.org/t/build-fails-vtk9-expected/16658/3 "2021-03-24T04:18:18Z")

</div>

To follow up, errors discussed here have been fixed by @lassoan in these commits:

- [COMP: Fix build error with VTK8 · Slicer/Slicer@7eb86ab · GitHub](https://github.com/Slicer/Slicer/commit/7eb86ab4e4e7450c58359e30a64cc474368266be)
- [COMP: Fix remaining build error with VTK8 · Slicer/Slicer@2f15e45 · GitHub](https://github.com/Slicer/Slicer/commit/2f15e458f3a4af5f6c4ca33ffe6a301fdce7b820)
