# Error on linux when creating QVTKOpenGLNativeWidget

**URL:** https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083
**Category:** Support
**Created:** [June 25, 2021, 8:34pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083 "2021-06-25T20:34:52Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![DLevy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dlevy/32/3615_2.png) [@DLevy](https://discourse.vtk.org/u/DLevy)
#### Post date: [June 25, 2021, 8:34pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083/1 "2021-06-25T20:34:52Z")

</div>

Hello,  
I am using VTK 9 + Qt6 in windows without any issue. I am now trying to build my application on linux, but I have errors when I instanciate the QVTKOpenGLNativeWidget and do nothing more than displaying it.

```auto
    mVTKWidget = new QVTKOpenGLNativeWidget;
    mVTKWidget->setMinimumSize( 400, 200 );
    lVLayout->addWidget( mVTKWidget );
    mVTKWidget->update();

```

It gives me error:

```auto
2021-06-25 16:00:47.175 ( 2.920s) [593F58C0] vtkShaderProgram.cxx:452 ERR| vtkShaderProgram (0x560b2d21cea0)
...
...

2021-06-25 16:00:47.176 ( 2.921s) [593F58C0] vtkShaderProgram.cxx:453 ERR| vtkShaderProgram (0x560b2d21cea0): 0:31(22): error: syntax error, unexpected NEW_IDENTIFIER, expecting '{'

2021-06-25 16:00:47.176 ( 2.921s) [593F58C0]vtkOpenGLVertexArrayObj:265 ERR| vtkOpenGLVertexArrayObject (0x560b2d732100): attempt to add attribute without a program for attribute ndCoordIn
2021-06-25 16:00:47.176 ( 2.921s) [593F58C0]vtkOpenGLQuadHelper.cxx:62 WARN| Error binding ndCoords to VAO.
2021-06-25 16:00:47.176 ( 2.921s) [593F58C0]vtkOpenGLRenderWindow.c:1031 ERR| vtkGenericOpenGLRenderWindow (0x560b2bdc3340): Couldn't build the shader program for resolving msaa.

```

Then it still kinda work.  
If I display points, everything is fine. But if I try to display vtkQuad or vtkHexahedron using a vtkCellArray, it crashes with this error:

```auto
2021-06-25 16:27:10.714 ( 7.349s) [537E58C0] vtkShaderProgram.cxx:452 ERR| vtkShaderProgram (0x55a52b556c60): 1: #version 140

...
...
2021-06-25 16:27:10.751 ( 7.386s) [537E58C0] vtkShaderProgram.cxx:453 ERR| vtkShaderProgram (0x55a52b556c60): 0:133(45): error: `gl_PrimitiveID' undeclared
0:133(45): error: operands to arithmetic operators must be numeric
0:133(18): error: no function with name 'texelFetchBuffer'
0:134(41): warning: `texColor' used uninitialized
0:135(41): warning: `texColor' used uninitialized
0:136(35): warning: `texColor' used uninitialized

```

Im trying to run this on a Ubuntu 20.04.

Any idea on why could cause this?  
Do I need to install something on my Ubuntu?  
Or maybe a compilation option?

Thanks

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [June 27, 2021, 2:17pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083/2 "2021-06-27T14:17:52Z")

</div>

Hi, David,

Make sure you have the latest version of your graphics card driver, which includes the OpenGL backend. If you’re using WLS, make sure you have WLS2.

take care,

Paulo

---

<div class="post-metadata">

### Author: ![DLevy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dlevy/32/3615_2.png) [@DLevy](https://discourse.vtk.org/u/DLevy)
#### Post date: [June 28, 2021, 2:33pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083/3 "2021-06-28T14:33:17Z")

</div>

Im trying to run it on virtual box.  
3D acceleration was disabled, so I tried to enable it, and force openGL3 with ‘LIBGL\_ALWAYS\_SOFTWARE=1’, but I have the same errors.

Is it supposed to work on virtualbox?

By they way, its good to know for wsl2

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [June 28, 2021, 3:26pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083/4 "2021-06-28T15:26:55Z")

</div>

`LIBGL_ALWAYS_SOFTWARE` should be zero, right?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [June 28, 2021, 3:33pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083/5 "2021-06-28T15:33:56Z")

</div>

VB used to have GPU passthrough, but it has been dropped some versions ago. So I guess you have to stick to software-only OpenGL. But I think you’re better off by trying WSL2 if you have Windows 10.

---

<div class="post-metadata">

### Author: ![DLevy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dlevy/32/3615_2.png) [@DLevy](https://discourse.vtk.org/u/DLevy)
#### Post date: [June 28, 2021, 5:49pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083/6 "2021-06-28T17:49:40Z")

</div>

Ok, I just setup server X to use WSL2. I followed this:

> <https://stackoverflow.com/questions/61110603/how-to-set-up-working-x11-forwarding-on-wsl2/62977642#62977642>

I have the same errors.

Setup info, does it look correct?

```auto
glxinfo -B
name of display: 192.168.64.1:0
display: 192.168.64.1:0 screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Mesa/X.org (0xffffffff)
    Device: llvmpipe (LLVM 11.0.0, 256 bits) (0xffffffff)
    Version: 20.2.6
    Accelerated: no
    Video memory: 11074MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 4.5
    Max compat profile version: 3.1
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
OpenGL vendor string: Mesa/X.org
OpenGL renderer string: llvmpipe (LLVM 11.0.0, 256 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 20.2.6
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 3.1 Mesa 20.2.6
OpenGL shading language version string: 1.40
OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 20.2.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

```

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [June 29, 2021, 12:27pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083/7 "2021-06-29T12:27:11Z")

</div>

Hmmm… I may be missing something, but why do use a X server to use WSL? WSL is supposed to allow you to run Linux executables directly under Windows. No need for emulation, X clients/servers, etc. Just run the binary as you’d do with a .EXE.

---

<div class="post-metadata">

### Author: ![DLevy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dlevy/32/3615_2.png) [@DLevy](https://discourse.vtk.org/u/DLevy)
#### Post date: [June 29, 2021, 1:08pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083/8 "2021-06-29T13:08:33Z")

</div>

As far as I understood, you need a X server, and if I try without one I have an error

There is a preview build ([Run Linux GUI apps with WSL | Microsoft Docs](https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps)) that allow wsl to run linux app without X server, but its not released yet

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [June 29, 2021, 1:15pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083/9 "2021-06-29T13:15:36Z")

</div>

True. GUI programs need to stream their graphical output somewhere.

---

<div class="post-metadata">

### Author: ![DLevy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dlevy/32/3615_2.png) [@DLevy](https://discourse.vtk.org/u/DLevy)
#### Post date: [June 29, 2021, 1:21pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083/10 "2021-06-29T13:21:40Z")

</div>

And from a comment, it seems its an Xserver implementation:

```auto
By default, its graphic drivers (llvmpipe) are run in software mode so if you want to do some serious hardware acceleration GUI, you have to install these:

1. GPU drivers specifically for WSL functionality
2. Latest mesa drivers from PPA. 

Right now, hardware acceleration in WSL only up to OpenGL 3.0 at the moment so running OpenGL 4.0 applications will throw out an error. Also for AMD GPU users, it is strongly recommended to install OpenGL & OpenCL compatibility pack from windows store. Windows 11 is already supporting WSL2 gui but with the right setup you can get linux gui apps launched without any 3rd party apps.

```

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [June 29, 2021, 1:33pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083/11 "2021-06-29T13:33:21Z")

</div>

It seems to me that your program is trying to call the deprecated `texelFetchBuffer` function in one of your shader scripts: [updating texelFetchBuffer to texelFetch · Issue #1 · raganmd/learningGLSL · GitHub](https://github.com/raganmd/learningGLSL/issues/1), so it fails to compile, triggering the error of your original post. According to what I found in the Internet, you should change your program to use the `texelFetch` function instead.

---

<div class="post-metadata">

### Author: ![DLevy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dlevy/32/3615_2.png) [@DLevy](https://discourse.vtk.org/u/DLevy)
#### Post date: [June 29, 2021, 1:46pm UTC](https://discourse.vtk.org/t/error-on-linux-when-creating-qvtkopenglnativewidget/6083/12 "2021-06-29T13:46:52Z")

</div>

Well, for the first error, im not doing anything, im just instanciating and displaying the QVTKOpenGLNativeWidget.

And for the crash, the only different code is this:

```auto
    int i = 0;
    vtkSmartPointer<vtkPoints> lPoints = vtkSmartPointer<vtkPoints>::New();
    vtkSmartPointer<vtkActor> lActor = vtkSmartPointer<vtkActor>::New();
        // Create a quad on the four points
        vtkSmartPointer<vtkQuad> lQuad = vtkSmartPointer<vtkQuad>::New();
        // Create a cell array to store the quad in
        vtkSmartPointer<vtkCellArray> lQuads = vtkSmartPointer<vtkCellArray>::New();

        for( auto it = lCenterPoints.begin(); it < lCenterPoints.end(); ++it, ++i )
        {
            lPoints->InsertNextPoint( std::get<0>( *it ), std::get<1>( *it ), std::get<2>( *it ) );
            ++it;
            lPoints->InsertNextPoint( std::get<0>( *it ), std::get<1>( *it ), std::get<2>( *it ) );
            ++it;
            lPoints->InsertNextPoint( std::get<0>( *it ), std::get<1>( *it ), std::get<2>( *it ) );
            ++it;
            lPoints->InsertNextPoint( std::get<0>( *it ), std::get<1>( *it ), std::get<2>( *it ) );

            lQuad->GetPointIds()->SetId( 0, 4 * i );
            lQuad->GetPointIds()->SetId( 1, 4 * i + 1 );
            lQuad->GetPointIds()->SetId( 2, 4 * i + 2 );
            lQuad->GetPointIds()->SetId( 3, 4 * i + 3 );

            lQuads->InsertNextCell( lQuad );
        }

        // Create a polydata to store everything in
        vtkSmartPointer<vtkPolyData> lPolydata = vtkSmartPointer<vtkPolyData>::New();

        // Add the points and quads to the dataset
        lPolydata->SetPoints( lPoints );
        lPolydata->SetPolys( lQuads );
        lPolydata->GetCellData()->SetScalars( lColors );

        // Setup actor and mapper
        vtkSmartPointer<vtkPolyDataMapper> lMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
        lMapper->SetInputData( lPolydata );
        lActor->SetMapper( lMapper );

```

So I have no idea where I would use something how/where I could use texelFetchBuffer.

And our QA team, just tested it on a VmWare virtual machine (ubuntu 20.04), and its working.
