# Compile 9.0 without opengl

**URL:** https://discourse.vtk.org/t/compile-9-0-without-opengl/4026
**Category:** Support
**Created:** [August 19, 2020, 8:58pm UTC](https://discourse.vtk.org/t/compile-9-0-without-opengl/4026 "2020-08-19T20:58:27Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![wenyan4work](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wenyan4work/32/2217_2.png) [@wenyan4work](https://discourse.vtk.org/u/wenyan4work)
#### Post date: [August 19, 2020, 8:58pm UTC](https://discourse.vtk.org/t/compile-9-0-without-opengl/4026/1 "2020-08-19T20:58:27Z")

</div>

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](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

---

<div class="post-metadata">

### Author: ![wenyan4work](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wenyan4work/32/2217_2.png) [@wenyan4work](https://discourse.vtk.org/u/wenyan4work)
#### Post date: [August 20, 2020, 2:52pm UTC](https://discourse.vtk.org/t/compile-9-0-without-opengl/4026/2 "2020-08-20T14:52:02Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pranjal.sahu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/pranjal.sahu/32/6052_2.png) [@pranjal.sahu](https://discourse.vtk.org/u/pranjal.sahu)
#### Post date: [July 19, 2021, 12:20am UTC](https://discourse.vtk.org/t/compile-9-0-without-opengl/4026/3 "2021-07-19T00:20:14Z")

</div>

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 …/

---

<div class="post-metadata">

### Author: ![rakesh205](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rakesh205/32/3984_2.png) [@rakesh205](https://discourse.vtk.org/u/rakesh205)
#### Post date: [September 23, 2021, 9:22am UTC](https://discourse.vtk.org/t/compile-9-0-without-opengl/4026/4 "2021-09-23T09:22:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![gmm9uf](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gmm9uf/32/5552_2.png) [@gmm9uf](https://discourse.vtk.org/u/gmm9uf)
#### Post date: [July 25, 2022, 4:54pm UTC](https://discourse.vtk.org/t/compile-9-0-without-opengl/4026/5 "2022-07-25T16:54:10Z")

</div>

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?
