I have one working installation on my Mac without visualisation enabled and it works fine.
I am trying to have another build with QT enabled so that I can visualise my detector. The configuration and build and installation of G4 were done successfully without any errors. But I get errors when running the test example B1.
I used ccmake and set the following options when building geant4.
GEANT4_BUILD_MULTITHREADED ON
GEANT4_INSTALL_DATA ON
GEANT4_USE_GDML ON
GEANT4_USE_QT ON
GEANT4_USE_RAYTRACER_X11 ON
GEANT4_USE_SYSTEM_EXPAT ON
QT_DIR /usr/local/opt/qt@5/lib/cmake/Qt5
Qt53DCore_DIR /usr/local/opt/qt@5/lib/cmake/Qt53DCore
Qt53DExtras_DIR /usr/local/opt/qt@5/lib/cmake/Qt53DExtras
Qt53DInput_DIR /usr/local/opt/qt@5/lib/cmake/Qt53DInput
Qt53DLogic_DIR /usr/local/opt/qt@5/lib/cmake/Qt53DLogic
Qt53DRender_DIR /usr/local/opt/qt@5/lib/cmake/Qt53DRender
Qt5Core_DIR /usr/local/opt/qt@5/lib/cmake/Qt5Core
Qt5Gamepad_DIR /usr/local/opt/qt@5/lib/cmake/Qt5Gamepad
Qt5Gui_DIR /usr/local/opt/qt@5/lib/cmake/Qt5Gui
Qt5Network_DIR /usr/local/opt/qt@5/lib/cmake/Qt5Network
Qt5OpenGL_DIR /usr/local/opt/qt@5/lib/cmake/Qt5OpenGL
Qt5Widgets_DIR /usr/local/opt/qt@5/lib/cmake/Qt5Widgets
Qt5_DIR /usr/local/opt/qt@5/lib/cmake/Qt5
X11_xcb_xkb_INCLUDE_PATH /usr/local/include
ccmake …/B1 does not give any error, but running the make command gives the following errors.
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1301:
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qtypeinfo.h:240:1: error: use of undeclared identifier ‘QT_VERSION_MAJOR’
Q_DECLARE_MOVABLE_CONTAINER(QMap);
^
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qtypeinfo.h:232:21: note: expanded from macro ‘Q_DECLARE_MOVABLE_CONTAINER’
isStatic = (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)),
^
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:57:42: note: expanded from macro ‘QT_VERSION’ #define QT_VERSION QT_VERSION_CHECK(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH)
^
There are more errors but they are essentially a repeat of what I have pasted above. If more information is needed, I can attach the full output as a text file.
I remember encountering this problem earlier but I do not recall how I solved it. Any help would be greatly appreciated.
I turned off X11 and rebuilt it but still got the same errors.
PS: I do not have qt6 installed. I do have qt5, qt@5 and qt4 on my machine and qt@5 is being used by geant4.
The paths of all directories that have qt in their name are as follows:
/usr/local/opt/qt5/
/usr/local/opt/qt@4/
/usr/local/opt/qt@5/
/usr/local/opt/qt-legacy-formula/
/usr/local/opt/qt-webkit@2.3/
I wish to add that when I do a new build, I delete the build and the install directories and then redo the building process from the source code. I have not used ‘make clean’ yet and wondered if that would help.
Thanks for the info! Unfortunately I can’t see anything obviously wrong with the compile command - it pretty much matches what I get on a local build except for the arm64 flags (I’m not on an Intel machine). I can only think of three things to check:
Run:
find /opt/homebrew/opt/qt@5/ -type f -exec grep -H "QT_VERSION_MAJOR" {} \;
and post the output here.
Run brew list --versions | grep qt and post the output here
Find the file named Geant4PackageCache.cmake under /Users/aneesha/geant4/geant4-v11.2.0-install-qt and post its contents here.
Thanks again, but I’m nearly at a complete loss to explain what the problem could be. The includes look fine, and the order should be fine. The only remaining things to try are:
Run brew doctor and fix any issues
Check that none of the qt formulae are linked, i.e. run brew unlink qt@4, brew unlink qt@5. Additionally check if there are any QtCore or qt headers left in /usr/local/include.
Reinstall the qt@5 formula just in case something has got corrupted/permissions
When building exampleB1 you could run ccmake and then edit CMAKE_CXX_FLAGS to add the -v flag. That will make the compile output very verbose and should show exactly what’s included and from where.
I did steps 3 and 1 and there were a couple of warnings after step 1 that I cleared up. After that, I rebuilt it (without deleting the already built geant I had) and ran the example B1 again. This time, the build was completed successfully. The file ./exampleB1 showed no warnings or errors but it also did not display the visualization window.
I have attached the first few lines of the output here: B1 output.txt (2.4 KB)
Do you have any suggestions on figuring out if qt is enabled?
I appreciate all the help you are providing. Thank you.
UPDATE: I switched off GDML and multithreading and built G4 with only qt ON and the visualization worked! I do not know if GDML/multithreading and QT are incompatible in some way or not.
The registered graphics systems (about line 12 of your log) show me Geant4 (the whole of Geant4, not just your app) has been built without visual graphics. (It shows only file-writing graphics systems.) So go back and rebuild with graphics options as described in the Installation Guide. I imagine you will want to add
to your cmake options. (Don’t forget to remove CmakeCache.txt - it remembers the past!!)
At this point you might get the same problem as before. Please follow Ben’s advice and run the brew doctor and unlink qt, etc. And if all fails, run with -v and post us the output.
Thank you for your response. I have a quick question.
If I have G4 running on my Mac with visualization, could you please tell me what file I am supposed to view to find out the settings that were used when building G4?