Geant4 11.0.0 on Mac OS

Hello all,
I wanted to ask if there is someone who could install geant4 11.0.0 with QT enabled on macOS bigsur or Monterey?

1 Like

yes, with bigsur I know it is no problem at all.
you could for example use homebrew to install qt (brew install qt@5) and the dependency expat library (brew install expat).
then simply follow the instructions on how to install geant4: Installation Guide — Geant4 Installation Guide 11.0 documentation

for qt make sure to add -DGEANT4_USE_QT=ON to the cmake command. If it does not find qt, just append -DCMAKE_PREFIX_PATH=$(brew --prefix qt@5).

remember to also follow the Postinstall Setup — Geant4 Installation Guide 11.0 documentation to set environment variables for every new terminal that you open

Hi,
Sorry to join in the middle but I have a somewhat related question. I’ve been trying to install geant4.11.0 on macOS Monterey 12.2 and I am having an issue with possibly missing .dylib files as shown in the error message below:

[ 83%] Linking CXX shared library …/BuildProducts/lib/libG4run.dylib
ld: can’t open file, errno=1 file ‘CMakeFiles/G4run.dir/run/src/G4PhysicsListHelper.cc.o’ for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [BuildProducts/lib/libG4run.dylib] Error 1
make[1]: *** [source/CMakeFiles/G4run.dir/all] Error 2

I started from the latest Xcode but later downgraded to 13.0 after learning about some issues with the latest Xcode and ROOT. I would really appreciate any help I can get.
Thanks.

Is the file CMakeFiles/G4run.dir/run/src/G4PhysicsListHelper.cc.o actually present on disk, and if so, what permissions does it have?

Hi Ben,
In fact the directory “CMakeFiles/G4run.dir” does not exist. My cmake version is 3.22.2. Thanks.

Thanks, that being the case, I’d suggest deleting this build directory and starting configuration and build again from scratch. A missing directory at this point suggests something very wrong with either the configuration or build. Whilst that’s annoying, it will give a fresh starting point to see if the issue reoccurs.

I tried as you suggested by deleting the build directory and starting from configuration and then make but the problem reoccured. If it’s useful at all, I successfully installed geant4.11.0 on our cluster with Red Hat 7 using the same cmake 3.22.2 and the folder “G4run.dir” does not exist under CMakeFiles there as well. So I’m a little confused as to why it is looking into a directory that does not exist. Thanks.

Apologies, I realised that I wasn’t very clear about where the directory should be. The location relative to the root of the build directory is source/CMakeFiles/G4run.dir/ and it should be present.

I’ve just tried building 11.0.0 on macOS 12.2.1, with CMake 3.22.2 and it configures and builds without error. Could you post the exact cmake commands used to configure and also run make VERBOSE=1 and post the compile/link command(s) that are run which cause the error please?

The following commands were used to configure:

cmake -DCMAKE_INSTALL_PREFIX=/Users/m254407/Research/MC/Geant4/11.0.0/geant4-v11.0.0-install -DGEANT4_INSTALL_DATA=ON -DGEANT4_INSTALL_DATADIR=/Users/m254407/Research/MC/Geant4/11.0.0/geant4-v11.0.0-data -DGEANT4_BUILD_MULTITHREADED=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_QT=ON /Users/m254407/Research/MC/Geant4/11.0.0/geant4-v11.0.0

and the following is the result of “make VERBOSE=1” (sorry for pasting it all here):

[ 84%] Linking CXX shared library …/BuildProducts/lib/libG4run.dylib

cd /Users/m254407/Research/MC/Geant4/11.0.0/geant4-v11.0.0-build/source && /Applications/CMake.app/Contents/bin/cmake -E cmake_link_script CMakeFiles/G4run.dir/link.txt --verbose=1

/Library/Developer/CommandLineTools/usr/bin/c++ -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe -Qunused-arguments -DGL_SILENCE_DEPRECATION -pthread -ftls-model=initial-exec -O3 -DNDEBUG -fno-trapping-math -ftree-vectorize -fno-math-errno -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk -dynamiclib -Wl,-headerpad_max_install_names -o …/BuildProducts/lib/libG4run.dylib -install_name @rpath/libG4run.dylib CMakeFiles/G4run.dir/run/src/G4AdjointPrimaryGeneratorAction.cc.o CMakeFiles/G4run.dir/run/src/G4AdjointSimManager.cc.o CMakeFiles/G4run.dir/run/src/G4AdjointSimMessenger.cc.o CMakeFiles/G4run.dir/run/src/G4ExceptionHandler.cc.o CMakeFiles/G4run.dir/run/src/G4MSSteppingAction.cc.o CMakeFiles/G4run.dir/run/src/G4MatScanMessenger.cc.o CMakeFiles/G4run.dir/run/src/G4MaterialScanner.cc.o CMakeFiles/G4run.dir/run/src/G4PhysicsListHelper.cc.o CMakeFiles/G4run.dir/run/src/G4PhysicsListOrderingParamater.cc.o CMakeFiles/G4run.dir/run/src/G4PhysicsListWorkspace.cc.o CMakeFiles/G4run.dir/run/src/G4Run.cc.o CMakeFiles/G4run.dir/run/src/G4RunManager.cc.o CMakeFiles/G4run.dir/run/src/G4MTRunManager.cc.o CMakeFiles/G4run.dir/run/src/G4WorkerRunManager.cc.o CMakeFiles/G4run.dir/run/src/G4RunManagerKernel.cc.o CMakeFiles/G4run.dir/run/src/G4MTRunManagerKernel.cc.o CMakeFiles/G4run.dir/run/src/G4WorkerRunManagerKernel.cc.o CMakeFiles/G4run.dir/run/src/G4RunMessenger.cc.o CMakeFiles/G4run.dir/run/src/G4UserPhysicsListMessenger.cc.o CMakeFiles/G4run.dir/run/src/G4UserRunAction.cc.o CMakeFiles/G4run.dir/run/src/G4MultiRunAction.cc.o CMakeFiles/G4run.dir/run/src/G4UserWorkerInitialization.cc.o CMakeFiles/G4run.dir/run/src/G4UserWorkerThreadInitialization.cc.o CMakeFiles/G4run.dir/run/src/G4VModularPhysicsList.cc.o CMakeFiles/G4run.dir/run/src/G4VPersistencyManager.cc.o CMakeFiles/G4run.dir/run/src/G4VUserActionInitialization.cc.o CMakeFiles/G4run.dir/run/src/G4VUserDetectorConstruction.cc.o CMakeFiles/G4run.dir/run/src/G4VUserParallelWorld.cc.o CMakeFiles/G4run.dir/run/src/G4VPhysicsConstructor.cc.o CMakeFiles/G4run.dir/run/src/G4VUserPhysicsList.cc.o CMakeFiles/G4run.dir/run/src/G4VUserPrimaryGeneratorAction.cc.o CMakeFiles/G4run.dir/run/src/G4WorkerThread.cc.o CMakeFiles/G4run.dir/run/src/G4RNGHelper.cc.o -Wl,-rpath,/Users/m254407/Research/MC/Geant4/11.0.0/geant4-v11.0.0-build/BuildProducts/lib …/BuildProducts/lib/libG4event.dylib …/BuildProducts/lib/libG4tracking.dylib …/BuildProducts/lib/libG4processes.dylib …/BuildProducts/lib/libG4digits_hits.dylib /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib/libexpat.tbd …/BuildProducts/lib/libG4track.dylib …/BuildProducts/lib/libG4geometry.dylib …/BuildProducts/lib/libG4graphics_reps.dylib …/BuildProducts/lib/libG4materials.dylib …/BuildProducts/lib/libG4particles.dylib …/BuildProducts/lib/libG4intercoms.dylib …/BuildProducts/lib/libG4global.dylib …/BuildProducts/lib/libG4clhep.dylib …/BuildProducts/lib/libG4ptl.0.0.2.dylib

ld: can’t open file, errno=1 file ‘CMakeFiles/G4run.dir/run/src/G4PhysicsListHelper.cc.o’ for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make[2]: *** [BuildProducts/lib/libG4run.dylib] Error 1

make[1]: *** [source/CMakeFiles/G4run.dir/all] Error 2

make: *** [all] Error 2

Just to double check again, is the directory source/CMakeFiles/G4run.dir/ present under the directory where you ran cmake and make? If so, does it contain anything, and if so is there a directory source/CMakeFiles/G4run.dir/run/src/ and what are its contents if any?

Does BuildProducts/lib in the directory where you ran cmake and make contain anything?

I’m at a loss to explain what’s going on if any of these files/directories aren’t present. Something is very wrong with the generated Makefiles or the permissions on the system.

The directory “source/CMakeFiles/G4run.dir/” exists under the build directory from where I run CMake and make. The result of “ls -a source/CMakeFiles/G4run.dir/run/src/” results in the following:

-rw-r–r-- 1 root staff 22360 Feb 17 18:06 G4AdjointPrimaryGeneratorAction.cc.o
-rw-r–r-- 1 root staff 28963 Feb 17 18:06 G4AdjointPrimaryGeneratorAction.cc.o.d
-rw-r–r-- 1 root staff 26296 Feb 17 18:06 G4AdjointSimManager.cc.o
-rw-r–r-- 1 root staff 52108 Feb 17 18:06 G4AdjointSimManager.cc.o.d
-rw-r–r-- 1 root staff 30352 Feb 17 18:06 G4AdjointSimMessenger.cc.o
-rw-r–r-- 1 root staff 52125 Feb 17 18:06 G4AdjointSimMessenger.cc.o.d
-rw-r–r-- 1 root staff 28272 Feb 17 18:06 G4ExceptionHandler.cc.o
-rw-r–r-- 1 root staff 51485 Feb 17 18:06 G4ExceptionHandler.cc.o.d

I did not include other files in the folder. Similarly, the contents of the “BuildProducts/lib” inside the build directory are as follows:

lrwxr-xr-x 1 root staff 1 Feb 17 18:01 Darwin-clang → .
-rwxr-xr-x 1 root staff 4297040 Feb 17 18:02 libG4analysis.dylib
-rwxr-xr-x 1 root staff 646317 Feb 17 18:01 libG4clhep.dylib
-rwxr-xr-x 1 root staff 585539 Feb 17 18:03 libG4digits_hits.dylib

Again, I’ve kept the list short. It is a work provided laptop and I am the admin. I ran the build and compile commands with sudo. Thanks a lot for taking your time to look into this.

I would use a fresh build directory, and try again without sudo. no need for root privileges, espiecially when the install prefix is in your users home

Agree with @weller’s suggestion as the first step. Running as sudo/root could easily cause permissions issues.

Sorry for not being so clear with my last response. The result is the same regardless of whether I run the build and install commands with or w/o sudo. Also, each time I start with a fresh build directory. It always fails at the exact same point. Thanks.

I’m afraid I’m really at a loss to understand or explain why this is failing… There is _probably_something in the system setup or running environment that is nixing things, but it’s impossible from this distance to determine this. All I can suggest is the following:

  • In the non sudo build, again run ls -a source/CMakeFiles/G4run.dir/run/src/ and post the complete list here (don’t worry about it being long, we need to see it all).
  • In particular, check to see if there are files G4PhysicsListHelper.cc.o and G4PhysicsListHelper.cc.o.d
  • If either of these are missing, you can try the following:
    • From the build directory (i.e. where you ran cmake and make) run cd source
    • Then run make run/src/G4PhysicsListHelper.cc.o
    • If that succeeds, change back to the build directory cd ..
    • Run make again.

The other option is to try the Ninja build tool. Once that’s installed (see the preceding link for how to install), create a fresh build directory and run cmake -GNinja <argsasbefore>, then ninja.

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