Installing VTK in Ubuntu 18.04

Hello I am following this link: VTK/Building/Linux - KitwarePublic to install VTK in my system. But having a lot of troubles while doing that.

According to them, I downloaded the VTK-6.3.0.zip Version(as the latest one is not supported by the CMakeLists.txt I am using)
I extracted the downloaded file in a VTK folder.
I have installed Cmake version 3.10.2

Then I follow instructions:

mkdir VTK-build
cd VTK-build
ccmake …/VTK

I am getting the following error:

CMake Error at CMake/vtkCompilerExtras.cmake:47 (if):
if given arguments:

 "cc: error: ARGS: No such file or directory

cc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0

Copyright (C) 2017 Free Software Foundation, Inc.

This is free software" " see the source for copying conditions. There is
NO

warranty" " not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

" “VERSION_GREATER” “4.2.0” “AND” “BUILD_SHARED_LIBS” “AND”

VTK 6.3 should work but I would advocate using a more recent version. 8.2 comes to mind.

1 Like

VTK prior to 7.1 has this weird compiler version detection logic that needs updated for any new version of GCC. VTK 7.1 finally got rid of the check completely in favor of CMake support for the flag that was being checked for.

I would also highly recommend VTK 8.2.0 instead of 6.3.

Here’s how I just built it on my Ubuntu 18.04 laptop and installed to $HOME/vtk-inst:

sudo apt install cmake libavcodec-dev libavformat-dev libavutil-dev libboost-dev libdouble-conversion-dev libeigen3-dev libexpat1-dev libfontconfig-dev libfreetype6-dev libgdal-dev libglew-dev libhdf5-dev libjpeg-dev libjsoncpp-dev liblz4-dev liblzma-dev libnetcdf-dev libnetcdf-cxx-legacy-dev libogg-dev libpng-dev libpython3-dev libqt5opengl5-dev libqt5x11extras5-dev libsqlite3-dev libswscale-dev libtheora-dev libtiff-dev libxml2-dev libxt-dev qtbase5-dev qttools5-dev zlib1g-dev
git clone git@gitlab.kitware.com:vtk/vtk.git
cd vtk
git checkout v8.2.0
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/vtk-inst \
    -DCMAKE_INSTALL_RPATH=$HOME/vtk-inst \
    -DVTK_Group_Qt=ON \
    -DVTK_QT_VERSION=5 \
    -DVTK_Group_Imaging=ON \
    -DVTK_Group_Views=ON \
    -DModule_vtkRenderingFreeTypeFontConfig=ON \
    -DVTK_WRAP_PYTHON=ON \
    -DVTK_PYTHON_VERSION=3 \
    -DPYTHON_EXECUTABLE=/usr/bin/python3 \
    -DPYTHON_INCLUDE_DIR=/usr/include/python3.6 \
    -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so \
    -DBUILD_TESTING=OFF \
    -DVTK_USE_SYSTEM_LIBRARIES=ON \
    -DVTK_USE_SYSTEM_LIBPROJ4=OFF \
    -DVTK_USE_SYSTEM_GL2PS=OFF \
    -DVTK_USE_SYSTEM_LIBHARU=OFF \
    -DVTK_USE_SYSTEM_PUGIXML=OFF \
    -DCMAKE_BUILD_TYPE=Release \
    ..
make -j$(($(nproc) - 1))
make install
4 Likes

You are right, I reinstalled with 8.2 version and it worked.

Hi Elvis,
I am trying to install VTK 8.2 that may be required for another application. So, I tried to follow the commands you provided, but I get the following error:

nanay001@nanay001-Bonobo-WS:~/vtk-inst$ git clone git@gitlab.kitware.com:vtk/vtk.git
Cloning into ‘vtk’…
git@gitlab.kitware.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
nanay001@nanay001-Bonobo-WS:~/vtk-inst$

Please advise

Use the https protocol instead :
git clone https://gitlab.kitware.com/vtk/vtk.git

I ran the same commands again, but with the above protocol, and seem to work. Could you show me how to check if it has installed VTK correctly?

VTK is not installed. You just cloned the source.

See here for building and installation :

https://gitlab.kitware.com/vtk/vtk/blob/master/Documentation/dev/build.md

I am confused. I thought that running the last command “make install”, as I have shown in my thread above, installed VTK. What is this line for, if it does not install VTK?

It does. I misunderstood your comment.

To check VTK is installed correctly, you can check ~/vtk-inst

how about
pip install vtk

1 Like

Excuse me, I would like to ask you, I changed the path after “=” to my absolute path, but I found that there is nothing under this folder, I would like to ask, then where is my final installation location? Please give me some advice. Thank you very much

Did you run make install (or ninja install)?

I run make install

That should output a bunch of information about where things are going. Does it match where you think they should be?

The final installation location does not match what I thought. I think the installation location should be under the corresponding folder after the “=”(

), but I don’t know where the actual installation location is, it seems to be under build, I don’t know how to confirm where it was last installed

Try this
https://cmake.org/cmake/help/v3.0/variable/CMAKE_INSTALL_PREFIX.html

make DESTDIR=/home/john install

Tip for anyone out there who needs to build an older VTK version and get the error cc: error: ARGS: No such file or directory: This error seems to come from variable _gcc_version. You need to modify the REGEX MATCH above the _gcc_version line for each cmake file which raises the error. I did it by adding more digits to the regex, like so:
string(REGEX MATCH "[3456789]\\.[0-9]\\.[0-9]*"
I was able to compile VTK 6.2.0 on Ubuntu 20.04 this way.

1 Like

Hello, I am trying to compile VTK 8.2 in ubuntu 22 but stuck with this error. Can I get some help?

CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find LibPROJ (missing: LibPROJ_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  CMake/FindLibPROJ.cmake:43 (find_package_handle_standard_args)
  CMake/vtkModuleMacros.cmake:891 (find_package)
  ThirdParty/libproj/CMakeLists.txt:1 (vtk_module_third_party)