VTK + QT in emscripten webassembly: opengl ERROR: unknown type name 'PFNGLPUSHDEBUGGROUPPROC'; did you mean 'PFNGLPUSHDEBUGGROUPKHRPROC'

Our previous developer left but he only gave a little information on how he built the project in QT, but we saw that it was built succesfuly as we have seen it runing as a web page (our desktop QT that is).

here is what I did:

  1. I downloaded QT as an installer

  2. After download, I ran the Maintenance tool, Went to add or remove components.
    I Installed QT 6.5.0 and the platflorms
    MinGW 11.2.0 64 bit
    WebAssemby (single-threaded)
    WebAssembly (multi-threaded)
    I also downloaded under developer tools
    MingW 11.2.0 64 bit
    CMake 3.24.2

  3. I also downloaded (apart from QT)
    ninja 1.11
    Emscripted 3.1.25
    VTK 9.2.6

    I set qmake.bat from C:\Qt\6.5.0\wasm_singlethread\bin
    cmake from C:\Qt\Tools\CMake_64
    and mingw from C:\Qt\Tools\mingw1120_64\bin
    in the environment PATH variables.

  4. So I went ahead and follow instructions based from here Qt for WebAssembly | Qt 6.5
    I ran the configure with emscripten like the one bellow,

./emsdk install 3.1.25
   
 ./emsdk activate 3.1.25
   
 configure.bat -qt-host-path C:\Qt\6.5.0\mingw_64 -no-warnings-are-errors -feature-opengles3  -device-option QT_EMSCRIPTEN_ASYNCIFY=1 -platform wasm-emscripten -prefix $PWD/qtbase

cmake –build .

All of the above is executed inside the source folder C:\Qt\6.5.0\Src
And I specify mingw_64 as the host-path as it is the ONLY one that compiles properly.

  1. Then I downloaded VTK and build like this

    emsdk activate 3.1.25

    emsdk_env.bat

    emcmake cmake . -B C:\build-vtk-wasm -GNinja -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DVTK_ENABLE_LOGGING:BOOL=OFF -DVTK_ENABLE_WRAPPING:BOOL=OFF -DVTK_MODULE_ENABLE_VTK_hdf5:STRING=NO -DVTK_MODULE_ENABLE_VTK_RenderingContextOpenGL2:STRING=DONT_WANT -DVTK_MODULE_ENABLE_VTK_RenderingLICOpenGL2:STRING=DONT_WANT -DVTK_MODULE_ENABLE_VTK_RenderingCellGrid:STRING=NO -DVTK_MODULE_ENABLE_VTK_sqlite:STRING=NO -DCMAKE_INSTALL_PREFIX=C:\vtk-install

    ninja
    ninja install

Everything builts ok without error. So I went to our project and started the build

emsdk activate 3.1.25
emsdk_env.bat
qmake.bat OurProject.pro
mingw32-make

qmake.bat is from C:\Qt\6.5.0\wasm_singlethread\bin
while mingw32-make is from C:\Qt\Tools\mingw1120_64\bin
Then I got these errors

In file included from Ui\VTKWidgets\MyQVTKOpenGLWindow.cpp:46:
In file included from ..\..\dependencies\VTK-9.2.6\include\vtk-9.2\vtk_glew.h:47:
..\..\dependencies\VTK-9.2.6\include\vtk-9.2\vtkglew/include/GL/glew.h:24591:17: error: unknown type name
      'PFNGLPOPDEBUGGROUPPROC'; did you mean 'PFNGLPOPDEBUGGROUPKHRPROC'?
GLEW_FUN_EXPORT PFNGLPOPDEBUGGROUPPROC __glewPopDebugGroup;
                ^~~~~~~~~~~~~~~~~~~~~~
                PFNGLPOPDEBUGGROUPKHRPROC
C:\Qt\6.5.0\wasm_singlethread\include\QtGui/qopengles2ext.h:155:28: note: 'PFNGLPOPDEBUGGROUPKHRPROC' declared here
typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void);

Im not sure what is happening here? I went to the file and PFNGLPUSHDEBUGGROUPPROC is indeed defined properly in vtk-9.2\vtkglew/include/GL/glew.h
maybe there is a conflict between OpenGL versions?
Maybe i misconfigured VTK for opengl? I am not sure what is happening here now.

Ive been stuck wth this for over 2 weeks, please help

Hello @cebugdev

What is the value of VTK_OPENGL_USE_GLES in your CMakeCache.txt?

it is set to off in VTK CMakeCache.txt

//Use the OpenGL ES API
VTK_OPENGL_USE_GLES:BOOL=OFF

Should it be ON or Off is the correct behaviour for webasm?

This is my cmake for VTK that I used

emcmake cmake . -B C:\build-vtk-wasm -GNinja -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DVTK_ENABLE_LOGGING:BOOL=OFF -DVTK_ENABLE_WRAPPING:BOOL=OFF -DVTK_MODULE_ENABLE_VTK_hdf5:STRING=NO -DVTK_MODULE_ENABLE_VTK_RenderingContextOpenGL2:STRING=DONT_WANT -DVTK_MODULE_ENABLE_VTK_RenderingLICOpenGL2:STRING=DONT_WANT -DVTK_MODULE_ENABLE_VTK_RenderingCellGrid:STRING=NO -DVTK_MODULE_ENABLE_VTK_sqlite:STRING=NO -DCMAKE_INSTALL_PREFIX=C:\vtk-install

It should be on. Just add -DVTK_OPENGL_USE_GLES=ON to your cmake configure arguments.

i think it worked, thank you, i now reach the final stages of the build which is linking.

but I am having problem, seems like freetype for VTK and QT had a clash


wasm-ld: error: duplicate symbol: ft_mem_realloc
>>> defined in ../../dependencies/VTK-9.2.6/lib\\libvtkfreetype-9.2.a(ftbase.c.o)
>>> defined in C:/Qt/6.5.0/wasm_singlethread/lib/libQt6BundledFreetype.a(ftbase.c.o)

wasm-ld: error: duplicate symbol: FT_GlyphLoader_CheckPoints
>>> defined in ../../dependencies/VTK-9.2.6/lib\\libvtkfreetype-9.2.a(ftbase.c.o)
>>> defined in C:/Qt/6.5.0/wasm_singlethread/lib/libQt6BundledFreetype.a(ftbase.c.o)

wasm-ld: error: duplicate symbol: FT_GlyphLoader_CheckSubGlyphs
>>> defined in ../../dependencies/VTK-9.2.6/lib\\libvtkfreetype-9.2.a(ftbase.c.o)
>>> defined in C:/Qt/6.5.0/wasm_singlethread/lib/libQt6BundledFreetype.a(ftbase.c.o)

How do I handle this?

Have you tried -DVTK_MODULE_ENABLE_VTK_RenderingFreeType:STRING=DONT_WANT? @ben.boeckel may have some ideas.

It looks like 9.2.6 has some unmangled symbols. Can you please test 9.3.0.rc1 so we can fix it if it needs to be?

Tried this still getting the errors

wasm-ld: error: duplicate symbol: FT_GlyphLoader_CreateExtra
>>> defined in ../../dependencies/VTK-9.2.6/lib\\libvtkfreetype-9.2.a(ftbase.c.o)
>>> defined in C:/Qt/6.5.0/wasm_singlethread/lib/libQt6BundledFreetype.a(ftbase.c.o)

wasm-ld: error: duplicate symbol: ft_mem_realloc
>>> defined in ../../dependencies/VTK-9.2.6/lib\\libvtkfreetype-9.2.a(ftbase.c.o)
>>> defined in C:/Qt/6.5.0/wasm_singlethread/lib/libQt6BundledFreetype.a(ftbase.c.o)

will try a different versions as suggested by Ben

Update: Tried a different version with 9.3 but same error :frowning:

Ok, it looks like we are missing some symbol manglings, at least on Windows. Can you please file an issue about this?

filed an issue in gitlab here: https://gitlab.kitware.com/vtk/vtk/-/issues/19129