Compiling geant4 on Mac M1

Dear all,

I am trying to compile geant4-v11.0.2 on Mac Monterey 12.3.1 with Qt5 by,

cmake -DCMAKE_INSTALL_PREFIX=../geant4-v11.0.2-install ../geant4-v11.0.2 -DGEANT4_USE_QT=ON -DCMAKE_PREFIX_PATH=/Users/ydu/Qt_/5.15.2/clang_64

until then it was successful,

GEANT4_USE_QT: Build Geant4 with Qt support
GEANT4_USE_QT3D: Build Geant4 Qt3D driver

-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ydu/geant4-v11.0.2-build

then I ran,

make

which ends up with the following error,

ld: warning: ignoring file /Users/ydu/Qt_/5.15.2/clang_64/lib/QtWidgets.framework/QtWidgets, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /Users/ydu/Qt_/5.15.2/clang_64/lib/QtGui.framework/QtGui, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /Users/ydu/Qt_/5.15.2/clang_64/lib/QtCore.framework/QtCore, 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::ClearButtonCallback() in G4UIQt.cc.o
      G4UIQt::SaveOutputCallback() in G4UIQt.cc.o
      G4UIQt::CommandEnteredCallback() in G4UIQt.cc.o
      G4UIQt::CommandEditedCallback(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/CMakeFiles/G4interfaces.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 82%] Built target G4processes
make: *** [all] Error 2

I browsed some posts on the forum and seemed to share a similar problem with many people, but none of their solutions worked for me. Could anyone be kind to give a hint?

Thanks in advance,
Chloe

Hi Chloe,

I am also on an M1 Mac, and while I didn’t have the exact issue you’re dealing with, I did find a method which seemed to compile and run Geant4 successfully using Qt5 and XQuartz for visualisation. In order to make it work, I needed to install cmake, Qt5, xorg-server, and X11 through MacPorts, and then I simply had to point cmake to the directories in which the correct X11 install lived (since cmake kept finding X11 in multiple locations on my machine, the other being the X11 that came when I installed XQuartz via DMG).

Perhaps you could give that a shot and see if you can get Geant4 compiled successfully?

Hi there,

Thanks so much for your reply! I sensed the error might be with the qt5 installation. I downloaded it via the online installer from qt website where I was expected to be guided to the right version for my machine, but I ran into the problem described as above. So I installed qt5 again using homebrew and this time everything worked just fine :grinning:

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