Home » Linux » getting error “GLintptr has not been declared” when building VTK on Linux

getting error “GLintptr has not been declared” when building VTK on Linux

Posted by: admin January 30, 2018 Leave a comment

Questions:

When building VTK on Linux, I get the following error:

In file included from /usr/include/GL/glx.h:333:0,
             from /home/mildred/Work/3DKF/VTK/Rendering/vtkXOpenGLRenderWindow.cxx:31:
/usr/include/GL/glxext.h:480:143: error: ‘GLintptr’ has not been declared
Answers:

The solution is to define GLX_GLXEXT_LEGACY during the build. This is done but commented in the file Rendering/vtkXOpenGLRenderWindow.cxx for VTK 5.x or Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx for VTK 6.x.

Either uncomment the line (this is for example an ArchLinux patch for the package):

--- a/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx.orig  2014-11-23 22:16:50.000000000 +0100
+++ b/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx   2014-11-23 22:16:59.000000000 +0100
@@ -27,7 +27,7 @@

 // define GLX_GLXEXT_LEGACY to prevent glx.h to include glxext.h provided by
 // the system
-//#define GLX_GLXEXT_LEGACY
+#define GLX_GLXEXT_LEGACY
 #include "GL/glx.h"

 #include "vtkgl.h"

Or, if you don’t want to be invasive on the source code, you can add the flags to the compiler command line. For example by adding -DCMAKE_C_FLAGS=-DGLX_GLXEXT_LEGACY -DCMAKE_CXX_FLAGS=-DGLX_GLXEXT_LEGACY to your cmake command line. Your cmake command will look like:

cmake -DCMAKE_C_FLAGS=-DGLX_GLXEXT_LEGACY -DCMAKE_CXX_FLAGS=-DGLX_GLXEXT_LEGACY -Wno-dev ../VTK