# Compiling ParaView with VTK\_USE\_X and VTK\_OPENGL\_HAS\_OSMESA simultaneously

**URL:** https://discourse.paraview.org/t/compiling-paraview-with-vtk-use-x-and-vtk-opengl-has-osmesa-simultaneously/4843
**Category:** ParaView Support
**Created:** [July 15, 2020, 3:10am UTC](https://discourse.paraview.org/t/compiling-paraview-with-vtk-use-x-and-vtk-opengl-has-osmesa-simultaneously/4843 "2020-07-15T03:10:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![cbutcher](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cbutcher/32/2013_2.png) [@cbutcher](https://discourse.paraview.org/u/cbutcher)
#### Post date: [July 15, 2020, 3:10am UTC](https://discourse.paraview.org/t/compiling-paraview-with-vtk-use-x-and-vtk-opengl-has-osmesa-simultaneously/4843/1 "2020-07-15T03:10:26Z")

</div>

I’m having some difficulties building with `VTK_USE_X=ON` and `VTK_OPENGL_HAS_OSMESA=ON` together as described at this link: [ParaView Docs - Offscreen](https://kitware.github.io/paraview-docs/v5.8.0/cxx/Offscreen.html).

Utkarsh Ayachit (in this thread: [osmesa linking problems](https://discourse.paraview.org/t/osmesa-linking-problems-compiling-paraview-on-opensuse-leap-15-1/4124/6)) suggested that I might not have a suitable Mesa installation.

**ParaView configuration attempts**  
When I tried to use both of those environment variables set to ON, I got a whole collection of OpenGL variables (each of which I set to my compiled copy of Mesa 20.1.3, with OSMesa and compiled using `-Dglx=dri -Dplatforms='drm,x11'` amongst other flags), but I was unable to find/use the OSMESA variables.

The GLU and xMesa variables I left with the system-detected libglu and unset, respectively. I also set `VTK_OPENGL_HAS_EGL=OFF`.

If I set them directly from the command line (rather than searching through and failing to find using ccmake) then I received warnings along the lines of ‘these variables were ignored’ (sorry, I forgot the exact wording) and then references to both `OSMESA_INCLUDE_DIR` and `OSMESA_LIBRARY`. These (the warnings) disappeared if I also passed `-DENABLE_osmesa=ON` but then I received a warning instead that that variable was ignored (it seems perhaps that is exclusively for the superbuild?).

When I set `VTK_USE_X=OFF`, the `OSMESA_{INCLUDE_DIR,LIBRARY}` variables appeared as expected and then compilation succeeded, and pvserver runs using MPI and forward/reverse connections as desired.

**Mesa configuration**  
My Mesa compilation command was:

> meson …/osmesa\_build/ -Dprefix=/appsdir/mesa/20.1.3 -Dglx=dri -Ddri3=false -Dllvm=true -Dosmesa=gallium -Dvulkan-drivers=‘’ -Dgallium-drivers=swr,swrast -Dgles1=false -Dgles2=false -Dopengl=true -Dgallium-vdpau=false -Dgallium-xvmc=false -Dgallium-va=false -Degl=true -Dshared-llvm=true -Dgbm=true -Ddri-drivers=‘’ -Dplatforms=‘drm,x11’

This produced pkgconfig files named for `dri.pc`, `egl.pc`, `gmb.pc`, `gl.pc` and `osmesa.pc`, along with libraries `libEGL.so`, `libGL.so`, `libOSMesa.so`, `libgbm.so`, `libglapi.so`, `libswrAVX.so` and `libswrAVX2.so`.

There was no `libGLX.so` produced, although the output of `readelf -s /appsdir/mesa/20.1.3/lib64/libGL.so.1.2.0 | grep 'glx'` did list a number of functions with names like `xcb_glx_...` (e.g. `xcb_glx_swap_buffers`).

A separate attempt using the following configuration also didn’t produce a libGLX, although it did remove the libEGL:

> meson …/osmesa\_build2/ -Dprefix=/appsdir/mesa/20.1.3.glx -Dglx=gallium-xlib -Ddri3=false -Dllvm=true -Dosmesa=gallium -Dvulkan-drivers=‘’ -Dgallium-drivers=swr,swrast -Dgles1=false -Dgles2=false -Dopengl=true -Dgallium-vdpau=false -Dgallium-xvmc=false -Dgallium-va=false -Degl=false -Dshared-llvm=true -Ddri-drivers=‘’ -Dplatforms=‘x11’

Should I be instructing ParaView to do something with the `libGL.so` specifically, or perhaps symbolic linking a `libGLX.so` to the libGL?

Alternatively, is there some key change I should make to the Mesa configuration, or do I need to additionally build and install some part of the Xorg libraries?

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [July 15, 2020, 10:32am UTC](https://discourse.paraview.org/t/compiling-paraview-with-vtk-use-x-and-vtk-opengl-has-osmesa-simultaneously/4843/2 "2020-07-15T10:32:03Z")

</div>

> [@cbutcher](#):
>
> There was no `libGLX.so` produced,

I misspoke. libGL is indeed what you want. libGL and libOSMesa.

The variables to set in ParaView config are:

- OpenGL\_GL\_PREFERENCE (set to LEGACY)
- OPENGL\_INCLUDE\_DIR
- OPENGL\_gl\_LIBRARY
- VTK\_OPENGL\_HAS\_OSMESA (set to ON)
- OSMESA\_INCLUDE\_DIR
- OSMESA\_LIBRARY

p.s. I have not tried this since `Mesa version 18.*`, but I’d suspect it still works with `20.*`.

---

<div class="post-metadata">

### Author: ![Maxime\_Boissonneault](https://discourse.paraview.org/user_avatar/discourse.paraview.org/maxime_boissonneault/32/4605_2.png) [@Maxime\_Boissonneault](https://discourse.paraview.org/u/Maxime_Boissonneault)
#### Post date: [August 3, 2020, 3:07pm UTC](https://discourse.paraview.org/t/compiling-paraview-with-vtk-use-x-and-vtk-opengl-has-osmesa-simultaneously/4843/3 "2020-08-03T15:07:13Z")

</div>

I think I am having the same problem. There is a library which should link against OSMesa.so, but it does not. I opened a bug report here:  
[https://gitlab.kitware.com/paraview/paraview/-/issues/20120](https://gitlab.kitware.com/paraview/paraview/-/issues/20120)
