CMake Error with VTK: "VTK::CommonColor" includes non-existent path

Hello,

I am encountering the following error when trying to configure a project with CMake using the example code from VTK Cylinder Example:

paar-orin1@ubuntu:~/overlay_cpp/deepstream_app/CylinderExample/build$ cmake ..
-- Configuring done
CMake Error in CMakeLists.txt:
  Imported target "VTK::CommonColor" includes non-existent path

    "/usr/local/include/vtk-9.4"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.
  * An install or uninstall procedure did not complete successfully.
  * The installation package was faulty and references files it does not provide.

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

I have installed VTK 9.1 using the package manager on my system:

paar-orin1@ubuntu:~/overlay_cpp/deepstream_app/CylinderExample/build$ dpkg-query -l | grep vtk
ii  libvtk9.1:arm64 9.1.0+really9.1.0+dfsg2-3build1 arm64 VTK libraries

However, CMake is looking for VTK version 9.4 headers in the path /usr/local/include/vtk-9.4, which doesn’t exist on my system. I’ve confirmed that I have VTK 9.1 installed and I haven’t installed version 9.4 manually.

Could anyone guide me on how to resolve this issue? It seems like CMake is incorrectly pointing to a non-existent version of VTK, or possibly there is a misconfiguration related to the version.

Any help would be greatly appreciated!

Are you sure you do not have another VTK somewhere on your machine ?

These are the all installed VTK-related packages on my system

paar-orin1@ubuntu:~/DiffuseSpheres/test$ dpkg -l | grep vtk
ii libvtk9-dev 9.1.0+really9.1.0+dfsg2-3build1 arm64 VTK header files
ii libvtk9-java 9.1.0+really9.1.0+dfsg2-3build1 arm64 VTK - Java language support
ii libvtk9.1:arm64 9.1.0+really9.1.0+dfsg2-3build1 arm64 VTK libraries
ii libvtk9.1-qt:arm64 9.1.0+really9.1.0+dfsg2-3build1 arm64 VTK libraries, Qt files
ii python3-vtk9 9.1.0+really9.1.0+dfsg2-3build1 arm64 Python bindings for VTK
ii vtk9 9.1.0+really9.1.0+dfsg2-3build1 arm64 Binaries for VTK9

"I installed the Python version of VTK using the following method:

python3 -m pip install "https://github.com/finsberg/vtk-aarch64/releases/download/vtk-9.2.6-cp310/vtk-9.2.6.dev0-cp310-cp310-linux_aarch64.whl"

This command downloads and installs a prebuilt wheel package for VTK version 9.2.6, specifically for Python 3.10 on the aarch64 architecture."

Can you try pointing the VTK_DIR to the right directory manually in your cmake command ?

I am sorry I didnt understand , can you explain in clear way

You are using the cmake command:

cmake ..

Instead use:

cmake -DVTK_DIR=/usr/local/include/vtk-9.1 ..

Adapt the path to the directory containing vtk-config.cmake.

I corrected the installation by using this command

cmake -DVTK_DIR=/usr/lib/cmake/vtk-9.1 ..

make

When I run the code

./CylinderExample

i got this as error :

paar-orin1@ubuntu:~/overlay_cpp/deepstream_app/CylinderExample/build$ ./CylinderExample
Segmentation fault (core dumped)

Build in debug and use gdb

Thank you for your previous assistance; my program is now working successfully. I am currently developing an application that integrates VTK, OpenCV, and DeepStream, and I need help creating a proper Makefile to ensure these libraries are correctly configured and accessible.

I encountered an issue related to rendering the window output when running my code and raised it on the VTK forum. For reference, here is the link to the issue I posted:

Could you please guide me in resolving this issue and in writing a proper Makefile for my application?