Errors building vtkGUISupportQt

I am building VTK 8.2.0 with Qt 5.12.12, using VS 2019. The build for vtkGUISupportQt fails with 27 errors in the compilation of QVTKOpenGLwidget.cxx. It is not obvious to me what the basic problem is, but many of the errors are related to:
identifier “QOpenGLFunctions_3_2_Core” is undefined.
but the include file OpenGLFunctions_3_2_Core.h is present.
Can somebody help?

8.2.0 is no longer supported, but it should have been tested with Qt 5.12 at the time. Does VTK 9.3 or master work?

This failure could be due to Qt configuration. In that header file, there is an #ifdef block:

#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
...

So if Qt was configured for OpenGL ES, or if it was configured for no OpenGL, then QOpenGLFunctions_3_2_Core will not be defined.

How was Qt installed?

Thanks David. I probably didn’t choose the right OpenGL options when building Qt. Can you tell me what I need to turn on?

~WRD0000.jpg

Do you think I should have built VTK 9.3? I chose an older version because a few years ago I was using Qt 4.8.1, and somehow I got the impression that I needed to stick to older versions for the VTK-Qt combo to work. I was flying blind.

I have problems with W10 at the moment (after resetting) and it’s not a good time to try building VTK again.

Take a look at https://doc.qt.io/qt-5/configure-options.html, it seems that the Qt config option that you want is

configure.bat -opengl desktop

If rebuilding Qt doesn’t fix the issue, you can additionally edit GUISupport/Qt/CMakeLists.txt make VTK bring in additional Qt components. For example, where it says

find_package(Qt5 COMPONENTS Widgets 

change to

find_package(Qt5 COMPONENTS Widgets OpenGL

and add these:

include_directories(${Qt5OpenGL_INCLUDE_DIRS})                                
add_definitions(${Qt5OpenGL_DEFINITIONS})
set(QT_LIBRARIES ${Qt5Widgets_LIBRARIES} ${Qt5OpenGL_LIBRARIES})

Possibly other stuff is needed as well. All of my advice here is just guesswork.

That’s a great help, David. I will try rebuilding Qt (a long process).

Thanks a lot.

Hi David. I rebuilt Qt5 with the “-opengl desktop” option, but as far as I can tell the result is identical to what I built before.
I then tried making the changes you suggested to GUISupport/Qt/MakeLists.txt. I now get the same errors in compiling QVTKOpenGLNativeWidget.cxx.
I am starting to wonder if it is in fact possible to build VTK with Qt5.
Thanks again for your suggestions.

In case my problem is related to a missing VTK module, I decided to try to build all modules (instead of just those related to Qt.) This gives me a cmake error:

CMake Error at C:/Program Files/CMake/share/cmake-3.30/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR)

To install Boost, do I need to build it from source?

On a different line of attack: I have been choosing to build Module_GuiSupportQt, but not Module_GUISupportQtOpenGL. Is it possible that I need to include the latter module in the build (if I do not build all module, which I currently can’t do, lacking Boost.)

Building all modules isn’t going to help you with Qt. Neither will Boost.

Thanks for that info, saving me from wasting more time.
I found that on GitHub Martijn Koopman has instructions for building Qt 5.13 and VTK 8.2: Qt-VTK-viewer. This looks promising, but the instructions specify, among other things that I have been doing, turning on:
VTK_BUILD_QT_PLUGIN
and
Module_vtkViewsQt
neither of which shows up in my configure with cmake_GUI. I don’t understand this.
I have tried to send a message to Martijn, via his website, but there’s no guarantee that he’ll be interested in fielding a query about this.

I forgot to mention that Martijn’s method builds VTK first (which is puzzling, because the build requires various cmake Qt options to be specified) then builds Qt with Qt Creator.

It shouldn’t be necessary to build Qt from source, since Qt 5.12 comes with a binary installer for Windows (qt-opensource-windows-x86-5.12.12.exe). I’ve never used this specific version of the installer, but I used the binary installer for Qt 5.9 (many years ago) and I don’t remember any particular difficulties building VTK with it.

I’ll look into the binary installation. It would be great if that enables VTK to be built with Qt5. I need 64-bit VTK, so that will need to be checked.

Thanks.

Hi David,

I finally got around to the binary install of Qt 5.12.12 as you suggested, and attempted to build VTK-8.2.0 with module_vtkGUISupportQtOpenGL. I get a great number of errors in the compilation of QVTKOpenGLNativeWidget.cxx, again related to QOpenGLFunctions_3_2_Core. There seems to be an incompatibility, related to OpenGL 3. Time to give up, I think.

Best regards,

Gib