Compile 9.0 without opengl

Is it possible to compile vtk 9.0 without opengl? The only thing we need is the IO module of legacy vtk files and binary xml vtk files (pvtp, vtp, pvtu, vtu, etc).

I found instructions about this from an email back in 2015: https://vtk.org/pipermail/vtkusers/2015-May/090922.html
Unfortunately, this doesn’t work anymore. CMake still complains that OpenGL is not found. Here is the output of CMake:
– Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY OPENGL_INCLUDE_DIR OpenGL)
CMake Error at CMake/vtkModule.cmake:4145 (message):
Could not find the OpenGL external dependency.
Call Stack (most recent call first):
CMake/vtkModule.cmake:4695 (vtk_module_find_package)
Utilities/OpenGL/CMakeLists.txt:58 (vtk_module_third_party_external)

How should I configure CMake of vtk-9?

Thank you

1 Like

Finally figured it out by trial-and-error. The old cmake macros in the 2015 email have been changed. Here is a cmake script that works for me:

cmake \

-D CMAKE_INSTALL_PREFIX:FILEPATH="$SFTPATH"
-D CMAKE_BUILD_TYPE:STRING=“Release”
-D BUILD_SHARED_LIBS=OFF
-D CMAKE_CXX_COMPILER:STRING=“mpicxx”
-D CMAKE_C_COMPILER:STRING=“mpicc”
-D CMAKE_CXX_FLAGS:STRING="$CXXFLAGS"
-D CMAKE_C_FLAGS:STRING="$CFLAGS"
-D OpenMP_CXX_FLAGS:STRING="$OPENMP_CXX_FLAGS"
-D OpenMP_C_FLAGS:STRING="$OPENMP_C_FLAGS"
-D BUILD_TESTING=OFF
-D VTK_PYTHON_VERSION=3
-D VTK_SMP_IMPLEMENTATION_TYPE=“OpenMP”
-D VTK_WRAP_PYTHON:BOOL=OFF
-D VTK_GROUP_ENABLE_Imaging=NO
-D VTK_GROUP_ENABLE_MPI=NO
-D VTK_GROUP_ENABLE_Qt=NO
-D VTK_GROUP_ENABLE_StandAlone=NO
-D VTK_GROUP_ENABLE_Views=NO
-D VTK_GROUP_ENABLE_Web=NO
-D VTK_MODULE_ENABLE_VTK_CommonCore=YES
-D VTK_MODULE_ENABLE_VTK_CommonExecutionModel=YES
-D VTK_MODULE_ENABLE_VTK_CommonMath=YES
-D VTK_MODULE_ENABLE_VTK_CommonMisc=YES
-D VTK_MODULE_ENABLE_VTK_CommonSystem=YES
-D VTK_MODULE_ENABLE_VTK_CommonTransforms=YES
-D VTK_MODULE_ENABLE_VTK_IOCore=YES
-D VTK_MODULE_ENABLE_VTK_IOLegacy=YES
-D VTK_MODULE_ENABLE_VTK_IOParallelXML=YES
-D VTK_MODULE_ENABLE_VTK_IOXML=YES
-D VTK_MODULE_ENABLE_VTK_IOXMLParser=YES
-D VTK_MODULE_ENABLE_VTK_ParallelCore=YES
$EXTRA_ARGS
$VTK_PATH

1 Like

This worked for me with VTK version 9.0.3.

cmake -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=RELEASE -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DVTK_USE_SYSTEM_EXPAT:BOOL=ON -DVTK_USE_SYSTEM_ZLIB:BOOL=ON -DVTK_LEGACY_REMOVE=ON -DVTK_Group_Rendering=OFF -DVTK_Group_StandAlone=OFF -DVTK_RENDERING_BACKEND=None -DVTK_WRAP_PYTHON=OFF -DModule_vtkCommonCore=ON -DModule_vtkCommonDataModel=ON -DModule_vtkFiltersCore=ON -DModule_vtkImagingStencil=ON -DModule_vtkIOXML=ON -DModule_vtkIOImage=ON -DModule_vtkImagingSources=ON -DVTK_GROUP_ENABLE_Views=NO -DVTK_GROUP_ENABLE_Web=NO -DVTK_GROUP_ENABLE_Imaging=NO -DVTK_GROUP_ENABLE_Qt=DONT_WANT -DVTK_GROUP_ENABLE_Rendering=DONT_WANT -GNinja …/

I have the same issue but after some correction, configured & make

BUILD_DOCUMENTATION OFF
BUILD_EXAMPLES OFF
BUILD_SHARED_LIBS ON
BUILD_TESTING OFF
BUILD_USER_DEFINED_LIBS OFF
CMAKE_BUILD_TYPE Release
CMAKE_INSTALL_PREFIX /usr/local
VTK_ANDROID_BUILD OFF
VTK_EXTRA_COMPILER_WARNINGS OFF
VTK_Group_Imaging OFF
VTK_Group_MPI OFF
VTK_Group_Qt OFF
VTK_Group_Rendering OFF
VTK_Group_StandAlone ON
VTK_Group_Tk OFF
VTK_Group_Views OFF
VTK_Group_Web OFF
VTK_IOS_BUILD OFF
VTK_PYTHON_VERSION 3
VTK_GLEXT_FILE /user/vtk/Utilities/ParseOGLExt/headers/glext.h
VTK_SMP_IMPLEMENTATION_TYPE Sequential
VTK_USE_LARGE_DATA OFF
VTK_WRAP_JAVA OFF
VTK_WRAP_PYTHON OFF
VTK_WRAP_TCL OFF

after that generate & make

It looks as though you all didn’t need the OpenGL library, so you wanted to turn off the error message. Is that right? I ask because it seems as though OpenGL would be necessary for visualizing anything, and isn’t that VTK’s main function? I am having the same problem as you all in finding OpenGL, but I feel like I’ll need VTK to find the OpenGL library, so I can’t just ignore the error message.

I see that in VTK documentation it says that “when a library such as OpenGL library is not located in the expected place, you will have to tell CMake the correct setting”, but I can’t seem to find where OpenGL is, and I am not sure what command line argument I would use to show where it is. Does anyone have any suggestions?