QCore/qconfig.h not found compiling application with Qt

Hi all! I’m compiling Geant4 v11.2.0 with Qt with no problem, but when I compile my own application I get the following error:

For some reason, my application fails to locate that particular header file, although it does locate the Qt installation and the Headers folders within it (and I’m not sure how… is that provided through the source of geant4.sh?).
If I add by hand the /opt/homebrew/opt/qt@5/include/ path to the list of folders of third-party headers, then the compilation succeeds; however, up to Geant4 v11.1.1, I didn’t need to specify it explicitly, so I was wondering if anything changed in the dependence of G4 from Qt.

I’m on a MacOS Ventura 13.3.1.

Thanks for your help



Did you have
-DCMAKE_PREFIX_PATH=“$(brew --prefix qt@5);”
in your Geant4 build?


Yes, I did! And the compilation ended successfully.

What CMake options did you use to configure/build Geant4 with, and are you building your application with CMake or another tool? If CMake, could you post the CMakeLists.txt script here please?

I used:


I use SCons to build my application, I attach the building file if it can be useful (I added a .txt extension to upload it here). As you can see, I don’t specify any locations for Qt, but that worked just fine up to the v11.1.2 version. Were the locations specified in the geant4.sh script?

SConstruct.txt (10.4 KB)

Sorry for the delay in replying here. Could you post the full compiler command line from the compilation that causes the error please? Nominally use of geant4-config (especially on macOS/Homebrew) should produce the correct series of flags, so something is either missing from that, or scons isn’t passing things through correctly.

I attach the output of geant4-config --cflags:

It seems that the /opt/homebrew/opt/qt@5/include/ path is not there, although I’m not sure it should appear. I checked with the v11.1.1 installation and it’s not there, either, but in that case it works anyway.

In the SConstruct file I use geant4-config to locate the relevant libraries, and in fact the /opt/homebrew/opt/qt@5/libQtCire.framework/Headers path is found correctly.

The command line for compilation is simply scons:

Thanks, but it’s the command line that Scons generates to compile nexus.cc as that will have the compiler command and all the flags used (ie. something like /path/to/compiler -I/a -I/b ... nexus.cc. I haven’t used Scons for a while, but there should be an command line flag to turn on verbose output of the commands it’s executing to do the compilation.

I can’t find an option to see the full command line, but all the flags used by the compiler are stored automatically in the buildvars.scons file, which I attach.

buildvars.scons.txt (1.9 KB)

Thanks for the details, and I think I understand what’s going on here now. Geant4 11.2 introduced beta support for Qt6, so there is a check on Qt version now in G4VisExecutive and a hard dependence on the Qt headers. This wasn’t present prior to this version with the Qt dependence being completely private (i.e. the headers were never needed), so 11.2 has exposed a bug in the header paths stored in geant4-config for macOS framework installs of Qt.

I’ve created a Bugzilla Ticket to track this, but in the meantime, your workaround of adding /opt/homebrew/opt/qt@5/include/ to the include path is the best thing to do.

That’s great, thank you!

From the release notes of g4-v11.2.1 (https://geant4-data.web.cern.ch/ReleaseNotes/Patch.11.2-1.txt) I understand that this problem should be fixed.
However, I installed the version with the new patch and I get the same error. Is there a specific flag that I should use in the cmake configuration step?

What does geant4-config --cflags print for you now, and can you confirm the geant4-config being executed is the one from the new 11.1.2 installation. I’ve tried locally and cannot reproduce the issue.

This is the output:

-I/usr/X11R6/include -DG4VIS_USE_OPENGL -DG4UI_USE_TCSH -DG4UI_USE_QT -DG4VIS_USE_OPENGLQT -DG4VIS_USE_TOOLSSG_QT_GLES -I/opt/homebrew/opt/qt@5/lib/QtCore.framework -I/opt/homebrew/opt/qt@5/lib/QtCore.framework/Headers -I/opt/homebrew/opt/qt@5/.//mkspecs/macx-clang -I/opt/homebrew/opt/qt@5/lib/QtGui.framework -I/opt/homebrew/opt/qt@5/lib/QtGui.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/opt/homebrew/opt/qt@5/lib/QtWidgets.framework -I/opt/homebrew/opt/qt@5/lib/QtWidgets.framework/Headers -I/opt/homebrew/opt/qt@5/lib/QtOpenGL.framework -I/opt/homebrew/opt/qt@5/lib/QtOpenGL.framework/Headers -F/opt/homebrew/Cellar/qt@5/5.15.8_3/lib -DG4UI_USE_QT3D -DG4VIS_USE_OPENGLX -DG4VIS_USE_TOOLSSG_X11_GLES -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe -Qunused-arguments -DGL_SILENCE_DEPRECATION -pthread -ftls-model=initial-exec -std=c++17 -I/Users/paola/Software/geant4-v11.2.1/include/Geant4

Yes, I’m using geant4-v11.2.1.

Hmm, the -F path is there so this is a bit confusing. Could you create a file, say test.cc with the content:

#include "G4VisExecutive.hh"
int main() {}

and try compiling that with:

$ clang++ $(geant4-config --cflags) test.cc

or whatever full path to geant4-config for the 11.2.1 version is needed.

That should compile without error.

I did what you suggested and I still get the same error (output attached).

Apologies, your code does work (I was picking up the wrong G4 version).

O.k., if that’s working, then building your full code with v11.2.1 should also work as that basically exercises the problem. What output/error are you seeing in the build of your code - is it picking up the correct Geant4 version, or has SCons cached something?

Sorry, my fault! My code actually compiles, I just needed to do a clean compilation from scratch.
The issue is settled, then, thanks for your help!