Error building with VTK support

I’m trying to build G4 with VTK support. I have built VTK 9.1 (latest) from source (the only way to get a vtk-config.cmake file?), but I get this during G4 compilation:

/root/src/source/interfaces/common/src/ fatal error: QVTKOpenGLNativeWidget.h: No such file or directory
   43 | #include "QVTKOpenGLNativeWidget.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [source/CMakeFiles/G4interfaces.dir/build.make:219: source/CMakeFiles/G4interfaces.dir/interfaces/common/src/] Error 1

What’s missing here?


I installed Vtk with homebrew on my Mac some months ago - it works fine (version 9.0.1_9). The above mentioned files are:


This is probably not relevant to your problem, but I would not put Geant4 source under /root/ - using root is dangerous. Also, there is normally another level of (sub-)directory, geant4-v11.0.0, if you have downloaded in the canonical way:


Its absence may be confusing the cmake system. (Anyway, always good to keep different versions in separate directories.)

Hope that helps

I’m building a Docker image, this is why I am root inside :wink:

Anyways, the header G4 is looking for does not really exist, I checked. Maybe something changed in VTK 9.1? I will investigate.

Got it, one needs to build VTK with Qt support, see Documentation/dev/ · master · VTK / VTK · GitLab.

Thank you for this useful information, Luigi.

A side note: it seems to me that the only way to have vtk-config.cmake installed (this is what CMake looks for when configuring the G4 build) is to build VTK from source. I tried installing official binaries but could not make VTK discoverable by G4.

Does anyone have any experience with this?

That’s what you said originally, but then I replied that my installation with home brew is fine.

@allison Doesn’t Homebrew do build-from-source? I haven’t had to install anything new in a while, but my memory is that it downloads a tarball, and does a compile-link-install build. Maybe it depends on the particular package…

Yes, the Homebrew bottle comes from a source build. What is a bit unfortunate is that (as far as I understand) the official VTK Python Wheels do not ship with the CMake config file.

FYI: I’m struggling to build VTK with Qt support in my Docker container. I opened a new topic on the VTK forum.

In general getting Vtk working from within docker is a challenge. Can I ask what your host system is? If it a Mac as the old OpenGL Xwindows support on Mac means a software renderer will have to be used.

I have fragments of docker files that might be able to help you, I’ll dig links to them for you

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.