Any guides for building VTK on Ubuntu 18.04 using WSL?


I am trying to build VTK 8.1 for Linux basically in WSL, because I want to incorporate this functionality showcasen here in my own code;

I am struggling quite a bit, since I am able to build it succesfully and find some of the header files, but for some reason some files like;


Are not found and I am pretty clueless to why that would be the case?

I am able to find all of the five header files given in the example, but am not able to find some of their dependencies, i.e. the two mentioned above.

Kind regards

Are you trying to build VTK or the example? Sorry, it isn’t very clear to me.

Sorry for being unclear!

I am basically trying to build VTK, but I can’t get the examples to work either. Whenever I try to follow the steps in the example, it just ends up saying “Skipping …” etc.

For me the priority is just to get VTK working so I can use it in my own package, but it is just not building everything I want unfortunately.

Kind regards

Hi, Ahmed,

Let’s do one thing at a time. First try to build VTK successfully. Trying to build the examples while VTK is incomplete will only create more confusion.
So, when you try to build VTK, what error are you getting? Forget about the examples for now.



Okay sure. Sorry it took a bit long to answer, for some reason configuration is taking ages right now…

My Goal: Compile VTK with the header files I need to implement it in my own code

Basically what I have done is to download a .tar file with the source code, and then I am using cmake gui, to try to compile the VTK. First I click “Configure”, (I use Unix Makefiles) which goes smoothly. It is able to find the C++ compiler etc. I select the unzipped tar as the “source” and then make a new directory called “build” to hold the compiled files.

Usually I would say “Generate” now, but for some reason the configuration is now producing errors.CMakeError.log (75.5 KB) CMakeOutput.log (294.3 KB)

So I am a bit at a loss. Basically I just want to use the header files, but whenever I try to compile I meet a new error each time…

Kind regards

CMake works in configuration cycles. Once you change something, you need to hit “Configure” again. You keep hitting “Configure” again after each cycle until you don’t get new variables (highlighted in red). Only after the configuration stabilized (and without errors), you click “Generate”. If you generate the Makefile too early, the build will be incomplete.

I have been trying for the past few hours, but it just won’t work. I am able to build but it never does generate any of the files, I want, i.e.;

#include “vtkCellArray.h”

#include <vtkPoints.h>

#include <vtkXMLPolyDataWriter.h>

#include <vtkPolyData.h>

#include <vtkSmartPointer.h>

And on top of that it doesn’t built the dependencies which it needs to make sure these files actually function.

Would anyone happen to know if there is a place with a step-by-step procedure, where somebody goes through how to actually do this in Linux? I’ve tried for 5 hours straight right now and have not moved an inch.

When I did this on Windows it was so easy, but Linux is just proving to be such a hassle right now.

Kind regards

Can you copy paste the output you see in the cmake-gui?

Okay so thank God, I finally got it to work. Basically I did as one should always do:

  1. Download VTK from somewhere, i.e. clone from Github, I went with version 9
  2. Then I made a new dir, vtk-build
  3. Then build vtk inside of this new dir, think it was ccmake path/to/vtk …

Select your options and build. So after this was done, it was actually “working”, but for some reason there were some errors with the vtk-config.cmake file. One was a missing space, which was just a warning, the other was more serious, where a function called “REMOVE” was called, but this function does not exist. My brother noticed that one could try “REMOVE_ITEM” and then the code worked (no guarantee of this being correct way though). So now I can finally run the example I mentioned in my post and produce the .vtp file.

Now my challenge lies in how I can include this functionality into my own project, since I have typically been using native make files only.

Kind regards and thanks for everyone trying to help me out

So, did you build VTK successfully? After building, did you deploy it? Building you generally do with a make command in your build directory. Deploying you generally do with a make install also in your build directory. The make install command copies all VTK’s .h, .a and .so files to the directory specified in CMAKE_INSTALL_PREFIX variable in CMake configuration.

Once all the .h, .a and .so files (collectivelly known as the SDK or devel package) are in the deploy directory (ex.: /usr/bin64/vtk8.1), you can proceed to configure, build and deploy the examples.

1 Like

Oh no, I didn’t do anything with “make install”, didn’t know that this was actually required. I basically followed the first two steps here,, “Download” and “Configure”.

I can try make install tomorrow, thanks for making me aware of it!

Kind regards

Well, that’s building instructions. After you build it, you need to deploy it. Software deployment is another operation in the so-called DevOps. For experimentation purposes, deploying is simply done with a make install or similar step. But, please, go back to CMake and double-check the directory set in CMAKE_INSTALL_PREFIX variable. The build artifacts will be copied there.

I went ahead and did what you suggested and it still works now, but produced same bugs as earlier, so I had to fix that again. The “make install” also at the end said it needed root permission or something so maybe one should have marked it used “sudo” as well.

Never the less, it works now and thank you very much for your help.

Kind regards

1 Like

Sorry, I forgot to tell you to prepend sudo to the make install command if CMAKE_INSTALL_PREFIX points to a system directory (e.g. /usr/bin64). Anyway, you can set CMAKE_INSTALL_PREFIX to any directory you want in case you are not in the sudoers list, which is often the case in coporate environments due to IT security policies.

1 Like

Thanks @Paulo_Carvalho for patiently explaining the issue. I learned something from it and it helped me trying to build vtk.

1 Like