Cant run make command on example B4a, gets error QtGlobal, no such file or directory

Geant4 Version: 11.2.2
Operating System: Ubuntu 24.04.1 LTS
Compiler/Version: gcc and g++
CMake Version: 3.28.3

I’m new to geant4, cmake, linux, and pretty much everything involved in this so forgive me if this is a simple fix. I’m trying to make example B4a but I keep getting the error shown below. The only reason I’ve found for it online has been that my G4VisExecutive.icc is corrupted. However, I’ve managed to run example B1 without any issues, so what would be causing this?

{
Making dependency for file exampleB4a.cc ...
In file included from /home/user/software/geant4/geant4-v11.2.2/source/visualization/management/include/G4VisExecutive.hh:141,
                 from exampleB4a.cc:38:
/home/user/software/geant4/geant4-v11.2.2/source/visualization/management/include/G4VisExecutive.icc:142:10: fatal error: QtGlobal: No such file or directory
  142 | #include <QtGlobal>
      |          ^~~~~~~~~~
compilation terminated.
Making dependency for file src/SteppingAction.cc ...
Making dependency for file src/RunAction.cc ...
Making dependency for file src/PrimaryGeneratorAction.cc ...
Making dependency for file src/EventAction.cc ...
Making dependency for file src/DetectorConstruction.cc ...
Making dependency for file src/ActionInitialization.cc ...
Making dependency for file exampleB4a.cc ...
In file included from /home/user/software/geant4/geant4-v11.2.2/source/visualization/management/include/G4VisExecutive.hh:141,
                 from exampleB4a.cc:38:
/home/user/software/geant4/geant4-v11.2.2/source/visualization/management/include/G4VisExecutive.icc:142:10: fatal error: QtGlobal: No such file or directory
  142 | #include <QtGlobal>
      |          ^~~~~~~~~~
compilation terminated.
Compiling ActionInitialization.cc ...
Compiling DetectorConstruction.cc ...
Compiling EventAction.cc ...
Compiling PrimaryGeneratorAction.cc ...
Compiling RunAction.cc ...
Compiling SteppingAction.cc ...
Creating shared library /home/summer/geant4_workdir/tmp/Linux-g++/exampleB4a/libexampleB4a.so ...
Compiling exampleB4a.cc ...
In file included from /home/user/software/geant4/geant4-v11.2.2/source/visualization/management/include/G4VisExecutive.hh:141,
                 from exampleB4a.cc:38:
/home/user/software/geant4/geant4-v11.2.2/source/visualization/management/include/G4VisExecutive.icc:142:10: fatal error: QtGlobal: No such file or directory
  142 | #include <QtGlobal>
      |          ^~~~~~~~~~
compilation terminated.
make: *** [/home/user/software/geant4/geant4-v11.2.2/config/binmake.gmk:446: /home/user/geant4_workdir/tmp/Linux-g++/exampleB4a/exe/exampleB4a.o] Error 1
}

Hi Spencer_House

It works for B1, but not for B4a? There must be some difference in your build instructions. QtGlobal is part of the Graphical User Interface system, Qt, and usually you have to tell Geant4 where it is.

I suspect you have a Geant4 build without Qt and you are trying to build B4a with Qt. You also have to build Geant4 itself with Qt.

The Application Developer’s Guide suggests you build your app (B4a in this case) by running cmake:

$ cmake -DCMAKE_PREFIX_PATH=/home/you/geant4-install $HOME/B4a

then

make

but before that, you have to build and install Geant4. If you want to use Qt, you have to have (amongst other options):

cmake ... -DGEANT4_USE_QT=ON -DCMAKE_PREFIX_PATH=<path-to-Qt> ...

Note that the Qt-related cmake options are supplied for the Geant4 build, and are not needed for your app build (it picks them up from the Geant4 build).

At least, I think that’s how it all works. Does this help? Maybe with B1 you were not asking for Qt and for B4a you decided to add the GEANT4_USE_QT flag, but only to the B4a build? Or you didn’t specify CMAKE_PREFIX_PATH. Something like that. Just go through the build and install steps carefully again. Good luck.

John

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