39

I want to install VTK in Ubuntu. CMake sends me this error :

CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message): Could NOT find OpenGL (missing: OPENGL_gl_LIBRARY OPENGL_INCLUDE_DIR) Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-2.8/Modules/FindOpenGL.cmake:161 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
Rendering/OpenGL/CMakeLists.txt:196 (find_package)

CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: OPENGL_INCLUDE_DIR (ADVANCED) used as include directory in directory /home/pilou/Documents/src/VTK-6.2.0/Geovis/Core

I have hence installed freeglut3 and build-essential (as I have seen on Internet). But nothing has changed.

How could I find opengl to write my own link to CMake? What else could I do to install VTK?

guhur
  • 2,500
  • 1
  • 23
  • 33

4 Answers4

58

EDIT Following the answer, we don't need to install freeglut (SDK for windows) but installing mesa is enough.

You can install mesa an implementation of OpenGL. See indications in the answer.

Therefore, if you have an error such that:

Could NOT find OpenGL

Then, you want to install libgl1-mesa-dev. With debian-based system:

sudo apt-get install libgl1-mesa-dev

For an error, such that:

Could NOT find OpenGL (missing: EGL)

Then, you want to install libegl1-mesa-dev. With debian-based system:

sudo apt-get install libegl1-mesa-dev

guhur
  • 2,500
  • 1
  • 23
  • 33
  • 1
    I am using a ubuntu server. But I cannot install it, like you described it. It says, that It cannot find te package. – Makuna Oct 04 '18 at 04:41
  • Installation of completely irrelevant packages just to get their dependencies as a side effect is overkill (unless you actually want these packages). The way to go is to install the exact packages you need, see my answer to learn which. – Ruslan Dec 10 '19 at 18:47
  • Yes you are right. I update my answer to avoid misleading people – guhur Dec 13 '19 at 10:09
  • How can I install it without root? Not all users can install libraries. How can I install it with conda? – GoingMyWay Dec 24 '21 at 15:43
19

You don't need any version of GLUT to satisfy a dependency on OpenGL. What you need is OpenGL headers and libraries. In Ubuntu they are installed with the libgl1-mesa-dev package.

To get the EGL build dependencies, replace the gl1 part of package name with egl1.

Ruslan
  • 18,162
  • 8
  • 67
  • 136
  • how is this ment? could u give me the exact steps pls? – Synaps Jan 15 '20 at 23:37
  • 1
    I installed the packages but it's complaining about `-- Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY OpenGL)` – Saeed Masoomi Sep 24 '21 at 08:08
  • @SaeedMasoomi what if you install `libgl-dev`? – Ruslan Sep 24 '21 at 09:05
  • @Ruslan, The cmake file needs to have the path to the OpenGL libraries, which is named `FindOpenGL.cmake`, unless the library cannot be found(My Ubuntu version is 20.4) . Everything is fine now, I appreciate your help – Saeed Masoomi Sep 24 '21 at 10:21
1

I have met the same problem, and however, none of the solutions proposed above helps me. In my case I found that there is no soft link for libGL.so, and so I just go to /usr/lib/x86_64-linux-gnu, and set up the soft link manually ln -s libGL.so.1 libGL.so. By the way, I meet the problem when I work on Docker container.

feelfree
  • 11,175
  • 20
  • 96
  • 167
0

Follow this tutorial to make sure drivers are installed and available for access:

Achint Sharma
  • 355
  • 4
  • 11