Geant4 10.6 and Qt

Hello, I try to install Geant4 10.6 with the option -DGEANT4_USE_QT=ON (“cmake --DGEANT4_USE_QT=ON …”) during the cmake step. Here is what I get

-- Detecting CXX compile features - done
-- Found EXPAT: /usr/lib64/libexpat.so (found version "2.2.7") 
CMake Error at /usr/share/cmake/Modules/FindQt4.cmake:1314 (message):
  Found unsuitable Qt version "5.12.6" from /usr/bin/qmake, this code
  requires Qt 4.x
Call Stack (most recent call first):
  cmake/Modules/Geant4InterfaceOptions.cmake:117 (find_package)
  cmake/Modules/G4CMakeMain.cmake:64 (include)
  CMakeLists.txt:50 (include)


-- Configuring incomplete, errors occurred!
See also "/home/pamputt/geant4.10.06/build/CMakeFiles/CMakeOutput.log".

I removed the first lines. I am a bit lost because it is written in the release notes that Qt4 is deprecated. Here cmake finds my version of Qt5 but does not want to use it. Any hints on how to solve that? I would prefer using Qt5 and not installing Qt4.

Here is the output of “qmake -v”

QMake version 3.1
Using Qt version 5.12.6 in /usr/lib64

Actually, GEANT4 is looking for Qt using /usr/share/cmake/Modules/FindQt4.cmake that try to find either Qt3 or Qt4 (but not Qt5). Yet Qt5Config.cmake is located in /usr/lib64/cmake/Qt5. How to point to the good cmake file?

In the documentation, it is written

See the CMAKE_PREFIX_PATH variable under Advanced Options if CMake has trouble locating Qt.

However, I tried to use cmake -DCMAKE_PREFIX_PATH=/usr/lib64/cmake/Qt5 -DGEANT4_USE_QT=ON .. without any success (same error).

The fallback to Qt4 should only happen if one or more of the following Qt5 packages were not found:

  • Qt5Core
  • Qt5Gui
  • Qt5Widgets
  • Qt5OpenGL
  • Qt5PrintSupport

As I don’t know what system you’re running on, I can’t advise which packages supply these, but there should be directories for each under /usr/lib64/cmake, e.g. /usr/lib64/cmake/Qt5Core.

Problem solved, actually Qt5OpenGL was missing. I installed it and now cmake goes further. Thanks
Is it documented somewhere that all these packages are needed?

Hi @bmorgan or @pamputt ,

I believe I am missing Qt5OpenGL, and am having trouble knowing how to obtain it. I’m on Linux Mint.

When I use cmake:

cmake -DCMAKE_INSTALL_PREFIX=/home/lorgum25/geant4.10.07.p02-install /home/lorgum25/geant4.10.07.p02 -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_OPENGL_X11=OFF -DGEANT4_USE_RAYTRACER_X11=ON -DGEANT4_USE_QT=ON -DGEANT4_USE_SYSTEM_EXPAT=ON

I get the following output:

CMake Error at cmake/Modules/G4InterfaceOptions.cmake:143 (find_package):
By not providing “FindQt5OpenGL.cmake” in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
“Qt5OpenGL”, but CMake did not find one.

Could not find a package configuration file provided by “Qt5OpenGL” with
any of the following names:

Qt5OpenGLConfig.cmake
qt5opengl-config.cmake

Add the installation prefix of “Qt5OpenGL” to CMAKE_PREFIX_PATH or set
“Qt5OpenGL_DIR” to a directory containing one of the above files. If
“Qt5OpenGL” provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
cmake/Modules/G4CMakeMain.cmake:64 (include)
CMakeLists.txt:51 (include)

– Configuring incomplete, errors occurred!
See also “/home/lorgum25/geant4.10.07-build/CMakeFiles/CMakeOutput.log”.
See also “/home/lorgum25/geant4.10.07-build/CMakeFiles/CMakeError.log”.

I have also inspected CMakeCache.txt:
I looked at the path directories used for Qt on my system to look for Qt5OpenGL, and find a folder name ‘Qt5OpenGLExtensions’.

Perhaps you are able to assist with this. Thank you.

I went and installed the Qt5 source code from scratch, but now I have Qt5OpenGL in a different folder…

Did you add the installation prefix of Qt to the CMAKE_PREFIX_PATH?
For example like this:

https://geant4-userdoc.web.cern.ch/UsersGuides/InstallationGuide/html/installguide.html#advancedoptions

  • GEANT4_USE_QT (DEFAULT : OFF)
    • If set to ON, build Qt5 User Interface and Visualization drivers.Requires: Qt5 and OpenGL libraries and headers.See the CMAKE_PREFIX_PATH variable under Advanced Options if CMake has trouble locating Qt.

Hi @weller, I thank you for your reply.

Your explanation of adding the installation path, based off the installation guide, is very clear, and I hope it is helpful to others.

I have realised my bigger issue was the way in which I was trying to install Qt5OpenGL, which was missing. I ended up messing up my system a lot, and had to get someone to help to restore it. We purged all of Qt in the process, and I am back at square one.

So I think that closes this question.

I have now used:

sudo apt-get install qt5-default qt5-qmake qtbase5-dev-tools qt5-doc

to install the required qt modules, and this has worked for me.