Building VTK in Ubuntu 21.04. OpenGL missing.


I tried to build VTK using the instructions on the GitHub page of VTK. I got the following error:

CMake Error at CMake/vtkModule.cmake:4579 (message):
Could not find the OpenGL external dependency.
Call Stack (most recent call first):
CMake/vtkModule.cmake:5173 (vtk_module_find_package)
Utilities/OpenGL/CMakeLists.txt:58 (vtk_module_third_party_external)

I tried to install OpenGL, but it depends on other packages. I tried to go down the chain in terms of dependencies, but unfortunately, cannot install OpenGL even after multiple attempts. I have implemented the following codes to install OpenGL and its various dependencies:

sudo apt-get install libegl1-mesa-dev
sudo apt-get install libgl1-mesa-dev
sudo apt update
sudo apt-get install freeglut3-dev
sudo apt reinstall freeglut3-dev
sudo apt --fix-broken install
sudo apt --fix-missing
sudo apt-get upgrade
sudo apt-get install mesa-utils
sudo apt install libgtkglext1

Thanking you

The ubuntu build-depends for vtk9 might provide some clues about what is missing. One package it suggests is libglu1-mesa-dev (the glu library that goes with the gl library).

But YMMV if you have third-party OpenGL drivers on your system.