# Build VTK 9.3.0 Msys2/Mingw64 on Win10 with OSMESA offscreen rendering

**URL:** https://discourse.vtk.org/t/build-vtk-9-3-0-msys2-mingw64-on-win10-with-osmesa-offscreen-rendering/13060
**Category:** Support
**Created:** [January 12, 2024, 10:39am UTC](https://discourse.vtk.org/t/build-vtk-9-3-0-msys2-mingw64-on-win10-with-osmesa-offscreen-rendering/13060 "2024-01-12T10:39:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tsobiech](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/e274bd/32.png) [@tsobiech](https://discourse.vtk.org/u/tsobiech)
#### Post date: [January 12, 2024, 10:39am UTC](https://discourse.vtk.org/t/build-vtk-9-3-0-msys2-mingw64-on-win10-with-osmesa-offscreen-rendering/13060/1 "2024-01-12T10:39:00Z")

</div>

### Description / Steps to reproduce the issue

I want to compile vtk with OSMESA offscreen rendering, instead of default Win32 OpenGL.

I based on package from the official repository [VTK](https://packages.msys2.org/base/mingw-w64-vtk)

In the file [PKGBUILD](https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-vtk/PKGBUILD), I only added this cmake flags:

```
${MINGW_PREFIX}/bin/cmake \
    ...
    -DVTK_USE_WIN32_OPENGL=OFF \
    -DVTK_OPENGL_HAS_OSMESA=ON \
    -DVTK_MODULE_ENABLE_VTK_MomentInvariants=NO \
    -DVTK_MODULE_ENABLE_VTK_RenderingOpenXR=NO \
    -DVTK_MODULE_ENABLE_VTK_RenderingLookingGlass=NO \
    ...

```

and I added more jobs to copiler, but it shouldn’t make any difference:

```
${MINGW_PREFIX}/bin/cmake --build . -- -j$(nproc)

```

The compilation was successful, and I installed the generated package without any problems:

```
pacman -U mingw-w64-ucrt-x86_64-vtk-9.3.0-4-any.pkg.tar.zst

```

I then successfully compiled the [OffScreenRendering](https://examples.vtk.org/site/Cxx/Utilities/OffScreenRendering/) example.

Example should produce `screenshot.png` file, but I got this error instead:

```
$ ./OffScreenRendering.exe
2024-01-12 11:28:03.616 ( 0.164s) [DA4A6AE7A9E48EB7]vtkOpenGLRenderWindow.c:704 ERR| vtkOSOpenGLRenderWindow (0x22cf2c7d930): GLEW could not be initialized: Missing GL version
[1] 9031 segmentation fault ./OffScreenRendering.exe

```

### Windows Version

```
$ uname

MINGW64_NT-10.0-19045

```

I performed the above steps on UCRT64 MINGW environments.

Is anyone able to help me solve this problem?

---

<div class="post-metadata">

### Author: ![tsobiech](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/e274bd/32.png) [@tsobiech](https://discourse.vtk.org/u/tsobiech)
#### Post date: [January 16, 2024, 11:12am UTC](https://discourse.vtk.org/t/build-vtk-9-3-0-msys2-mingw64-on-win10-with-osmesa-offscreen-rendering/13060/2 "2024-01-16T11:12:37Z")

</div>

I managed to solve the problem by using the internal GLEW instead of the external one.  
So I had to add an extra flag to cmake:

```auto
-DVTK_MODULE_USE_EXTERNAL_VTK_glew=OFF

```
