Trouble Building Geant4 with qt turned on in M1 mac

I am attempting to build geant4 v4.10.06.p03 on an M1 mac (running Big Sur, 11.6) with qt enabled. I have qt installed using homebrew and have been able to successfully install geant4 without the option turned on.

I paste a truncated error message below following running the cmake command:

cmake -DCMAKE_INSTALL_PREFIX=../geant4.10.06.p03 ../geant4.10.06.p03 -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_QT=ON

Error message after running make:

[  2%] Built target G4clhep
[  4%] Built target G4global
[  5%] Built target G4intercoms
[  5%] Built target G4zlib
[  7%] Built target G4analysis
[  8%] Built target G4materials
[  8%] Built target G4graphics_reps
[ 16%] Built target G4geometry
Consolidate compiler generated dependencies of target G4particles
[ 22%] Built target G4particles
Consolidate compiler generated dependencies of target G4track
[ 23%] Built target G4track
Consolidate compiler generated dependencies of target G4digits_hits
[ 26%] Built target G4digits_hits
Consolidate compiler generated dependencies of target G4processes
[ 81%] Built target G4processes
Consolidate compiler generated dependencies of target G4tracking
[ 82%] Built target G4tracking
Consolidate compiler generated dependencies of target G4event
[ 83%] Built target G4event
Consolidate compiler generated dependencies of target G4run
[ 84%] Built target G4run
Consolidate compiler generated dependencies of target G4error_propagation
[ 85%] Built target G4error_propagation
[ 85%] Linking CXX shared library ../../BuildProducts/lib/libG4interfaces.dylib
ld: warning: ignoring file /Users/mistryk2/opt/anaconda3/lib/libQt5PrintSupport.5.9.7.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /Users/mistryk2/opt/anaconda3/lib/libQt5Widgets.5.9.7.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /Users/mistryk2/opt/anaconda3/lib/libQt5Gui.5.9.7.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /Users/mistryk2/opt/anaconda3/lib/libQt5Core.5.9.7.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
  "QArrayData::deallocate(QArrayData*, unsigned long, unsigned long)", referenced from:
      G4UIQt::G4UIQt(int, char**) in G4UIQt.cc.o
      G4UIQt::CreateViewerWidget() in G4UIQt.cc.o
      G4UIQt::CreateUITabWidget() in G4UIQt.cc.o
      G4UIQt::CreateCoutTBWidget() in G4UIQt.cc.o
      G4UIQt::SetDefaultIconsToolbar() in G4UIQt.cc.o
      QString::~QString() in G4UIQt.cc.o
      int qRegisterMetaType<QTextCursor>(char const*, QTextCursor*, QtPrivate::MetaTypeDefinedHelper<QTextCursor, (QMetaTypeId2<QTextCursor>::Defined) && (!(QMetaTypeId2<QTextCursor>::IsBuiltIn))>::DefinedType) in G4UIQt.cc.o
  "QString::trimmed_helper(QString const&)", referenced from:
      G4UIQt::OpenHelpTreeOnCommand(QString const&) in G4UIQt.cc.o
      G4UIQt::CommandEnteredCallback() in G4UIQt.cc.o
  "QString::trimmed_helper(QString&)", referenced from:
      G4UIQt::FillHelpTree() in G4UIQt.cc.o
      G4UIQt::ReceiveG4cout(G4String const&) in G4UIQt.cc.o
      G4UIQt::ReceiveG4cerr(G4String const&) in G4UIQt.cc.o
      G4UIQt::CreateHelpTree(QTreeWidgetItem*, G4UIcommandTree*) in G4UIQt.cc.o
      G4UIQt::CommandEnteredCallback() in G4UIQt.cc.o
      G4UIQt::LookForHelpStringCallback() in G4UIQt.cc.o
  "QString::fromUtf8_helper(char const*, int)", referenced from:
      operator+(QString const&, char const*) in G4UIQt.cc.o
      G4UIQt::AddIcon(char const*, char const*, char const*, char const*) in G4UIQt.cc.o
      G4UIQt::OpenHelpTreeOnCommand(QString const&) in G4UIQt.cc.o
      G4UIQt::CreateCommandWidget(G4UIcommand*, QWidget*, bool) in G4UIQt.cc.o
      G4UIQt::GetLongCommandPath(QTreeWidgetItem*) in G4UIQt.cc.o
      G4UIQt::GetCommandList(G4UIcommand const*) in G4UIQt.cc.o
      G4UIQt::updateHelpArea(G4UIcommand const*) in G4UIQt.cc.o
      ...
  "QTextEdit::toPlainText() const", referenced from:
      G4UIQt::SaveOutputCallback() in G4UIQt.cc.o
  "QTextEdit::textColor() const", referenced from:
      G4UIQt::ReceiveG4cout(G4String const&) in G4UIQt.cc.o
      G4UIQt::ReceiveG4cerr(G4String const&) in G4UIQt.cc.o
  "typeinfo for QTabWidget", referenced from:
      typeinfo for G4QTabWidget in G4UIQt.cc.o
  "typeinfo for QDockWidget", referenced from:
      typeinfo for G4UIDockWidget in G4UIQt.cc.o
  "typeinfo for QGridLayout", referenced from:
      G4UIQt::VisParameterCallback(QWidget*) in G4UIQt.cc.o
  "typeinfo for QPushButton", referenced from:
      G4UIQt::CreateCommandWidget(G4UIcommand*, QWidget*, bool) in G4UIQt.cc.o
      G4UIQt::VisParameterCallback(QWidget*) in G4UIQt.cc.o
      G4UIQt::ChangeColorCallback(QWidget*) in G4UIQt.cc.o
  "typeinfo for QScrollArea", referenced from:
      G4UIQt::CreateVisCommandGroupAndToolBox(G4UIcommand*, QWidget*, int, bool) in G4UIQt.cc.o
  "typeinfo for QRadioButton", referenced from:
      G4UIQt::VisParameterCallback(QWidget*) in G4UIQt.cc.o
  "typeinfo for QLabel", referenced from:
      G4UIQt::VisParameterCallback(QWidget*) in G4UIQt.cc.o
  "typeinfo for QDialog", referenced from:
      G4UIQt::CreateCommandWidget(G4UIcommand*, QWidget*, bool) in G4UIQt.cc.o
  "typeinfo for QLayout", referenced from:
      G4UIQt::VisParameterCallback(QWidget*) in G4UIQt.cc.o
  "typeinfo for QObject", referenced from:
      G4UIQt::CreateVisCommandGroupAndToolBox(G4UIcommand*, QWidget*, int, bool) in G4UIQt.cc.o
      typeinfo for G4UIQt in moc_G4UIQt.cpp.o
  "typeinfo for QWidget", referenced from:
      G4UIQt::CreateVisCommandGroupAndToolBox(G4UIcommand*, QWidget*, int, bool) in G4UIQt.cc.o
      G4UIQt::CreateCommandWidget(G4UIcommand*, QWidget*, bool) in G4UIQt.cc.o
      G4UIQt::VisParameterCallback(QWidget*) in G4UIQt.cc.o
      G4UIQt::ChangeColorCallback(QWidget*) in G4UIQt.cc.o
      G4QTabWidget::paintEvent(QPaintEvent*) in G4UIQt.cc.o
  "typeinfo for QToolBox", referenced from:
      G4UIQt::CreateVisCommandGroupAndToolBox(G4UIcommand*, QWidget*, int, bool) in G4UIQt.cc.o
  "typeinfo for QComboBox", referenced from:
      G4UIQt::CreateCommandWidget(G4UIcommand*, QWidget*, bool) in G4UIQt.cc.o
      G4UIQt::VisParameterCallback(QWidget*) in G4UIQt.cc.o
  "typeinfo for QGroupBox", referenced from:
      G4UIQt::CreateVisCommandGroupAndToolBox(G4UIcommand*, QWidget*, int, bool) in G4UIQt.cc.o
  "typeinfo for QLineEdit", referenced from:
      G4UIQt::CreateCommandWidget(G4UIcommand*, QWidget*, bool) in G4UIQt.cc.o
      G4UIQt::VisParameterCallback(QWidget*) in G4UIQt.cc.o
  "typeinfo for QTextEdit", referenced from:
      G4QTabWidget::paintEvent(QPaintEvent*) in G4UIQt.cc.o
  "non-virtual thunk to QWidget::redirected(QPoint*) const", referenced from:
      vtable for G4QTabWidget in G4UIQt.cc.o
      vtable for G4UIDockWidget in G4UIQt.cc.o
  "non-virtual thunk to QWidget::initPainter(QPainter*) const", referenced from:
      vtable for G4QTabWidget in G4UIQt.cc.o
      vtable for G4UIDockWidget in G4UIQt.cc.o
  "non-virtual thunk to QWidget::paintEngine() const", referenced from:
      vtable for G4QTabWidget in G4UIQt.cc.o
      vtable for G4UIDockWidget in G4UIQt.cc.o
  "non-virtual thunk to QWidget::sharedPainter() const", referenced from:
      vtable for G4QTabWidget in G4UIQt.cc.o
      vtable for G4UIDockWidget in G4UIQt.cc.o
  "non-virtual thunk to QWidget::metric(QPaintDevice::PaintDeviceMetric) const", referenced from:
      vtable for G4QTabWidget in G4UIQt.cc.o
      vtable for G4UIDockWidget in G4UIQt.cc.o
  "non-virtual thunk to QWidget::devType() const", referenced from:
      vtable for G4QTabWidget in G4UIQt.cc.o
      vtable for G4UIDockWidget in G4UIQt.cc.o
  "operator==(QString const&, QString const&)", referenced from:
      G4UIQt::AddIcon(char const*, char const*, char const*, char const*) in G4UIQt.cc.o
      G4UIQt::FindTreeItem(QTreeWidgetItem*, QString const&) in G4UIQt.cc.o
      G4UIQt::CreateVisCommandGroupAndToolBox(G4UIcommand*, QWidget*, int, bool) in G4UIQt.cc.o
      G4UIQt::CreateCommandWidget(G4UIcommand*, QWidget*, bool) in G4UIQt.cc.o
      G4UIQt::ChangeCursorAction(QString const&) in G4UIQt.cc.o
      G4UIQt::ChangeSurfaceStyle(QString const&) in G4UIQt.cc.o
      G4UIQt::ChangePerspectiveOrtho(QString const&) in G4UIQt.cc.o
      ...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [BuildProducts/lib/libG4interfaces.dylib] Error 1
make[1]: *** [source/interfaces/CMakeFiles/G4interfaces.dir/all] Error 2
make: *** [all] Error 2

The compilation works with qt turned off: -DGEANT4_USE_QT=OFF.

Any help with this would be greatly appreciated. Thanks!

Hi

I think this is going to be tough. Geant4 10.6 was never built on Big Sur (Big Sur did not exist at that time), so there can be no guarantees.

Looking at your log, it also looks like there may also be system incompatibilities between the Qt installed from home brew and Big Sur:

Have you tried building the latest Geant4 11.0? That has been successfully built on Big Sur.

Sorry not to be more helpful.

John

No worries, that’s always the risk when you try to compile older versions on new machines! I’ll try building qt without homebrew and if that still gives me trouble I can try the version of geant4 you suggest. Thanks!

I think the issue may be more that the build is not picking up the Homebrew install of Qt5, but one from Anaconda:

Homebrew installs qt@5 in so called “keg only” mode, so to get CMake to find this you’ll need to do

cmake -DCMAKE_INSTALL_PREFIX=../geant4.10.06.p03 ../geant4.10.06.p03 -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_QT=ON -DCMAKE_PREFIX_PATH=$(brew --prefix qt@5)

Same caveats about trying to build an old version of Geant4 on a newer system, but the above may help…

Very good spot!

I also needed to force it to compile with C++17 by including -DCMAKE_CXX_FLAGS="-std=c++17" and also making sure I only had qt5 installed on my system (having both qt6 and qt5 seemed to give an error too).

I managed to compile both geant4 v10 an v11 with these fixes. Thanks very much!

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