'unknown type name QT6_VIRTUAL' on MacOS

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

_Geant4 Version: 11.2.2
_Operating System: MacOS Sonoma 14.6.1
_Compiler/Version: clang 12.0.0
_CMake Version: 3.30.2

I’m trying to build Geant4 on my Mac. This has worked before. Most of my packages were installed with homebrew and I just updated all of them. I built and installed CLHEP by hand (based on prior experience). I then configured cmake with the following (key) options shown at the bottom. Then I try to make geant4, and it dies with the following error:

[ 23%] Building CXX object source/CMakeFiles/G4digits_hits.dir/digits_hits/detector/src/G4CellScoreComposer.cc.o
In file included from /Users/prebys/installations/geant4/source/interfaces/implementation/src/G4UIQt.cc:49:
/usr/local/opt/qt5/lib/QtWidgets.framework/Headers/qlayout.h:129:5: error:
unknown type name ‘QT6_VIRTUAL’
QT6_VIRTUAL int indexOf(QLayoutItem *) const;
^
/usr/local/opt/qt5/lib/QtWidgets.framework/Headers/qlayout.h:134:5: error:
unknown type name ‘QT6_VIRTUAL’
QT6_VIRTUAL QLayoutItem *replaceWidget(QWidget *from, QWidget *to,
^
/usr/local/opt/qt5/lib/QtWidgets.framework/Headers/qlayout.h:134:28: error:
expected ‘;’ at end of declaration list
QT6_VIRTUAL QLayoutItem *replaceWidget(QWidget *from, QWidget *to,

I do have both qt5 and qt6 installed, but it should be looking only in the qt5 directory.

Any advice would be appreciated!

-Eric

cmake info…

CLHEP_DIR /usr/local/lib/CLHEP-2.4.7.1
CMAKE_BUILD_TYPE Release
CMAKE_INSTALL_PREFIX /usr/local
CMAKE_OSX_ARCHITECTURES
CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_OSX_SYSROOT /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk
GEANT4_BUILD_MULTITHREADED OFF
GEANT4_INSTALL_DATA ON
GEANT4_INSTALL_DATADIR
GEANT4_USE_G3TOG4 OFF
GEANT4_USE_GDML ON
GEANT4_USE_INVENTOR OFF
GEANT4_USE_INVENTOR_QT OFF
GEANT4_USE_OPENGL_X11 ON
GEANT4_USE_QT ON
GEANT4_USE_RAYTRACER_X11 ON
GEANT4_USE_SYSTEM_CLHEP ON
GEANT4_USE_SYSTEM_EXPAT ON
GEANT4_USE_SYSTEM_ZLIB OFF
GEANT4_USE_VTK OFF
GEANT4_USE_XM ON
QT_DIR /usr/local/opt/qt5/lib/cmake/Qt5
Qt53DCore_DIR /usr/local/opt/qt5/lib/cmake/Qt53DCore
Qt53DExtras_DIR /usr/local/opt/qt5/lib/cmake/Qt53DExtras
Qt53DInput_DIR /usr/local/opt/qt5/lib/cmake/Qt53DInput
Qt53DLogic_DIR /usr/local/opt/qt5/lib/cmake/Qt53DLogic
Qt53DRender_DIR /usr/local/opt/qt5/lib/cmake/Qt53DRender
Qt5Core_DIR /usr/local/opt/qt5/lib/cmake/Qt5Core
Qt5Gamepad_DIR /usr/local/opt/qt5/lib/cmake/Qt5Gamepad
Qt5Gui_DIR /usr/local/opt/qt5/lib/cmake/Qt5Gui
Qt5Network_DIR /usr/local/opt/qt5/lib/cmake/Qt5Network
Qt5OpenGL_DIR /usr/local/opt/qt5/lib/cmake/Qt5OpenGL
Qt5Widgets_DIR /usr/local/opt/qt5/lib/cmake/Qt5Widgets
Qt5_DIR /usr/local/opt/qt5/lib/cmake/Qt5
X11_xcb_xkb_INCLUDE_PATH /usr/local/include


Hi Eric

If you have both Qt5 and Qt6 installed with homebrew, for Qt5 you have to:
brew unlink qt
(Don’t ask me why.)

Does this help?
John

P.S. “brew link qt” if you build with Qt6.

Thanks!

That wast he magic bullet to get it to build.

Now on to the next problem…