Hi,
I try to compile vtk 9 rc1 with osmesa support. It seems that although I set the include and library path, those variables are not used by CMake in the build process. I configure as follows:
OSMESA_INCLUDE_DIR /home/angainor/mesa/install/include
OSMESA_LIBRARY /home/angainor/mesa/install/lib/x86_64-linux-gnu/libOSMesa.so
VTK_OPENGL_HAS_OSMESA = ON
When I compile, very early on I get the following error:
vtk/vtk-release/ThirdParty/glew/vtkglew/src/glew.c:41:12: fatal error: GL/osmesa.h: No such file or directory
41 | # include <GL/osmesa.h>
| ^~~~~~~~~~~~~
When I run make VERBOSE=1 I do not see the configured OSMESA include dir in the command line. I tried to explicitly add -I... to CXX and C flags. That works, but then I experience linker errors and unresolved symbols.
The same works with vtk 8.2. Is this a problem with v9?
Can you see what the VTK::opengl target looks like either by tracing the execution trhough Utilities/OpenGL/CMakeLists.txt or checking on what the VTK::opengl and VTK::glew target properties look like in the lib/cmake/vtk-9.0/VTK-targets.cmake file in the build tree?
Thanks, @ben.boeckel. In Utilities/OpenGL/CMakeLists.txt I see this:
if (VTK_OPENGL_HAS_OSMESA AND NOT VTK_CAN_DO_ONSCREEN)
vtk_module_third_party_external(
PACKAGE OSMesa
TARGETS OSMesa::OSMesa)
else ()
...
I don’t know what VTK_CAN_DO_ONSCREEN exactly means, but I guess it could be that osmesa is not used if onscreen rendering is available? There is no other mention of OSMesa in this file.
OK, the logic in CMake/vtkOpenGLOptions.cmake is going bad somewhere. If you trace it through, does anything not make sense in your setup? (FWIW, ParaView has OSMesa binaries that are working, but it probably is doing less than what your build is trying.)
In the meantime I tried a vanilla configure without any of my options. It seems that I can only set VTK_OPENGL_HAS_OSMESA, but the other two options I used from 8.2 are not available in ccmake advanced mode (OSMESA_INCLUDE_DIR and OSMESA_LIBRARY). I only find OPENGL_xmesa_INCLUDE_DIR OPENGL_xmesa_INCLUDE_DIR-NOTFOUND.
Am I using some deprecated variables here? Maybe I should provide the mesa installation location differently?
I’ll try that, thanks! but will I then be able to use the same compilation for both headless and on-screen visualization? or do I have to compile a separate installation for off-screen rendering?
Indeed, turning off VTK_USE_X gave me the option to set OSMESA paths. so I guess this is it.