Errors while building geant4 with qt5

Dear all,
I am trying to install geant4 v11.0.0 in my 2019 MacBook Pro (macOS Monterey) with qt enabled. But I have been getting the following errors

/usr/local/Cellar/qt@5/5.15.2_1/lib/QtGui.framework/Headers/qpixmap.h:134:31: error: unknown type name ‘QMatrix’
QPixmap transformed(const QMatrix &, Qt::TransformationMode mode = Qt::FastTransformation) const;
/usr/local/Cellar/qt@5/5.15.2_1/lib/QtGui.framework/Headers/qpixmap.h:136:12: error: unknown type name ‘QMatrix’
static QMatrix trueMatrix(const QMatrix &m, int w, int h);
/usr/local/Cellar/qt@5/5.15.2_1/lib/QtGui.framework/Headers/qpixmap.h:136:37: error: unknown type name ‘QMatrix’
static QMatrix trueMatrix(const QMatrix &m, int w, int h);

output.txt (14.8 KB)

I used the following cmake command to build geant4


I have been trying to resolve this since quite a long time, but I didn’t get any success till now. It would be really nice if someone could help me with it.


I see you have CMAKE_PREFIX_PATH twice. Not sure that’s OK - the second supersedes the first, I suspect. I would put


Do you have any other Qt installs on the system, such as Homebrew’s main qt package, which is Qt6, or any Anaconda/Conda installs?

Hi, I have brew qt6 installed.
One more information, if I build geant4 with gcc and g++ then I don’t get this error(qt). However I get an error message while running basic example B1.

In the install guide for version 11, it says the QT6 is not supported.

It’s possible that having the main qt (6) Formula installed is causing the build to pick up headers from this ahead of the qt@5 “keg only” that CMake found. Might be that /usr/local is appearing earlier in the include path.

I would try brew unlink qt and then try rebuilding Geant4 (you shouldn’t need to reconfigure, just rebuild). That should diagnose whether this is the case or not.

Note that we don’t test or support building/using Geant4 with GCC on macOS at the moment, so I’d go back to using the system Clang.


Hi Richard,
I am having cmake pointing to qt5.
But as morgan mentioned qt5 and qt6 are probably “mixing” up.

hi Morgan,
Thank you so much for the reply. Unlinking qt worked and I could build geant4 with qt enabled using clang.
Now I can run the examples smoothly

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