Skip to content
gemcPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

175 Commits

Folders and files

Repository files navigation

g4install

Deploy images Linux tarballs macOS tarball Nightly release Registry cleanup

g4install builds and manages Geant4 with versioned Environment Modules. It supports side-by-side Geant4 installations, relocatable binary tarballs, and multi-architecture container images.

Table of contents

Highlights

  • Install and switch between Geant4 versions.
  • Build matched CLHEP and Xerces-C dependencies automatically.
  • Use the same module layout on Linux and macOS.
  • Pull CI-built Linux images for amd64 and arm64.
  • Download relocatable Linux and Apple Silicon tarballs from the rolling development release.

Installation

Choose one route, complete its numbered instructions, then continue to compiling and running an example.

Route Choose it when Requirements
Build from scratch You need a local build or a custom Geant4 fork. Compiler, build tools, headers
Docker You want a ready-to-use environment with Geant4 and ROOT. Docker and space for the image
Binary installation You want local Geant4 without rebuilding it. Matching OS/CPU and runtime libraries

Option 1: Build from scratch

Step 1. Source-build prerequisites

Building locally requires a C++ compiler, CMake, Git, Z shell, Environment Modules, Qt 6, X11/OpenGL headers, expat, and zlib. The commands below match the libraries enabled by install_geant4. Run the command for your operating system with an account that has administrative privileges.

Fedora 44
sudo dnf install -y git make cmake gcc-c++ zsh environment-modules \
  expat-devel zlib-devel qt6-qtbase-devel \
  mesa-libGL-devel mesa-libGLU-devel libX11-devel libXpm-devel libXft-devel \
  libXt-devel libXmu-devel libXrender-devel
AlmaLinux 9.4
sudo dnf install -y 'dnf-command(config-manager)'
sudo dnf config-manager --set-enabled crb
sudo dnf install -y almalinux-release-synergy
sudo dnf install -y git make cmake gcc-c++ zsh environment-modules \
  expat-devel zlib-devel qt6-qtbase-devel \
  mesa-libGL-devel mesa-libGLU-devel libX11-devel libXpm-devel libXft-devel \
  libXt-devel libXmu-devel libXrender-devel
AlmaLinux 10
sudo dnf install -y 'dnf-command(config-manager)'
sudo dnf config-manager --set-enabled crb
sudo dnf install -y git make cmake gcc-c++ zsh environment-modules \
  expat-devel zlib-devel qt6-qtbase-devel \
  mesa-libGL-devel mesa-libGLU-devel libX11-devel libXpm-devel libXft-devel \
  libXt-devel libXmu-devel libXrender-devel
Ubuntu 24.04/26.04
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  git make cmake g++ zsh environment-modules libexpat1-dev zlib1g-dev \
  qt6-base-dev libqt6opengl6 libqt6openglwidgets6 qt6-base-dev-tools \
  libgl1-mesa-dev libglu1-mesa-dev libx11-dev libxpm-dev libxft-dev \
  libxt-dev libxmu-dev libxrender-dev
Debian 13
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  git make cmake g++ zsh environment-modules libexpat1-dev zlib1g-dev \
  qt6-base-dev libqt6opengl6-dev libqt6openglwidgets6 qt6-base-dev-tools \
  libgl1-mesa-dev libglu1-mesa-dev libx11-dev libxpm-dev libxft-dev \
  libxt-dev libxmu-dev libxrender-dev
macOS 26 (Apple Silicon - unfortunately Intel Macs are not supported)

Install the Xcode Command Line Tools first, then install the remaining dependencies with Homebrew:

xcode-select --install
brew install qt cmake modules
brew install --cask xquartz
export MODULESHOME="$(brew --prefix modules)"
source "$MODULESHOME/init/zsh"

Start a new login shell after installing the prerequisites so that the module command is initialized.

Step 2. Clone and register the modulefiles

The commands below install the repository in $HOME/g4install. Choose another absolute path if preferred.

git clone https://github.com/gemc/g4install.git "$HOME/g4install"
module use "$HOME/g4install/modules"
module avail geant4

Add the module use line to .bashrc or .zshrc to make the modulefiles available in future shells.

Step 3. Install Geant4 11.4.3

module load sim_system
install_geant4 11.4.3

The installer builds CLHEP and Xerces-C when needed, downloads the Geant4 datasets, and installs everything under $HOME/g4install/<platform>/. The build can take a while and requires several gigabytes of disk space.

Step 4. Load and verify the installation

module load geant4/11.4.3
geant4-config --version
command -v geant4-config

Optional: Install from a custom Geant4 repository

Install Geant4 from a custom repository using its Git URL and a unique install name. This also creates a module with the same name.

install_geant4 'ssh://git@github.com:7999/hello/hello-dev.git' hello-dev
module load geant4/hello-dev
geant4-config --version

The name selects both <g4install>/<platform>/geant4/hello-dev and the generated geant4/hello-dev module. The installer clones the default branch and uses the CLHEP and Xerces-C versions specified by geant4/dev. It creates the module only after a successful build and install.

Use --ref for a branch or tag and --prefix for a different absolute install path:

install_geant4 'git@github.com:hello/geant4.git' hello-custom \
  --ref my-branch --prefix "$HOME/software/geant4/hello-custom"
module load geant4/hello-custom

Option 2: Docker

Images include Geant4 and ROOT and are published in the GitHub Container Registry. All listed tags support batch operation. AlmaLinux 10 is headless; the other images also provide VNC/noVNC visualization.

Step 1. Docker prerequisites

Install Docker Desktop.

The supported images supply Geant4, its dependencies, and the build tools needed to compile and run Geant4 examples and applications. Start Docker before running the commands below on the host.

Step 2. Work directory

The -v "$HOME/mywork:/work" option mounts your host directory ~/mywork at /work inside the container. Save your source code, builds, and output under /work so they remain in ~/mywork after the container exits, even with --rm. The -w /work option starts the container in that directory.

Create the work directory:

mkdir -p "$HOME/mywork"

Step 3. Start a container

Run an interactive login shell:

docker run --rm -it \
  -v "$HOME/mywork:/work" -w /work \
  ghcr.io/gemc/g4install:11.4.3-ubuntu-24.04 bash -li

Start the default noVNC desktop, then open http://localhost:6080:

docker run --rm -it \
  -v "$HOME/mywork:/work" -w /work \
  -p 6080:6080 -p 5900:5900 \
  -e X11VNC_PASSWORD=change-me \
  -e VNC_BIND=0.0.0.0 \
  -e GEOMETRY=1920x1200 \
  ghcr.io/gemc/g4install:11.4.3-ubuntu-24.04

[!NOTE] Change the VNC password before exposing either port beyond your local machine.

Supported images

Geant4 11.4.3
Base image Registry tag Modes amd64 arm64
Ubuntu 24.04 ghcr.io/gemc/g4install:11.4.3-ubuntu-24.04 batch + noVNC yes yes
Ubuntu 26.04 ghcr.io/gemc/g4install:11.4.3-ubuntu-26.04 batch + noVNC yes yes
Fedora 44 ghcr.io/gemc/g4install:11.4.3-fedora-44 batch + noVNC yes yes
AlmaLinux 9.4 ghcr.io/gemc/g4install:11.4.3-almalinux-9.4 batch + noVNC yes yes
AlmaLinux 10 ghcr.io/gemc/g4install:11.4.3-almalinux-10 batch yes yes
Debian 13 ghcr.io/gemc/g4install:11.4.3-debian-13 batch + noVNC yes yes
Arch Linux latest ghcr.io/gemc/g4install:11.4.3-archlinux-latest batch + noVNC yes no
Special debug image

ghcr.io/gemc/g4install:11.4.3-ubuntu-26.04-debug is a special image for debugging and profiling. Geant4 and CLHEP are built with debug symbols using RelWithDebInfo, which keeps optimization enabled. It supports batch and VNC/noVNC operation, is available for amd64 only, and has no binary tarball. On arm64 hosts, use --platform=linux/amd64 with emulation:

docker run --rm -it --platform=linux/amd64 \
  -v "$HOME/mywork:/work" -w /work \
  ghcr.io/gemc/g4install:11.4.3-ubuntu-26.04-debug bash -li

Option 3: Binary installation

CI publishes relocatable tarballs to the rolling development release. Choose the archive matching your OS and CPU architecture.

Step 1. Binary-installation prerequisites

Install the shared-library dependencies below before using a tarball. These lists are generated from ci/binary_packages.py, the runtime-package source of truth used by CI. Run the command for your operating system with an account that has administrative privileges.

Each platform lists runtime dependencies first, followed by the compiler, CMake, Make, and development headers needed to compile examples in Step 2. CLHEP and Xerces-C are included in the archive; Environment Modules is not required for this route. On macOS, Qt and XQuartz also supply development headers; install the Xcode Command Line Tools and CMake for compilation.

Fedora 44

Runtime dependencies:

sudo dnf install -y --allowerasing \
  ca-certificates curl gzip tar expat \
  sqlite-libs zlib libX11 libXext libXmu \
  libXt mesa-libEGL mesa-libGL qt6-qtbase qt6-qtsvg \
  tbb

To compile examples, also install:

sudo dnf install -y make cmake gcc-c++ expat-devel zlib-devel qt6-qtbase-devel \
  mesa-libGL-devel mesa-libGLU-devel libX11-devel libXpm-devel libXft-devel \
  libXt-devel libXmu-devel libXrender-devel
AlmaLinux 9.4

Runtime dependencies:

sudo dnf install -y 'dnf-command(config-manager)'
sudo dnf config-manager --set-enabled crb
sudo dnf install -y almalinux-release-synergy
sudo dnf install -y --allowerasing \
  ca-certificates curl gzip tar expat \
  sqlite-libs zlib libX11 libXext libXmu \
  libXt mesa-libEGL mesa-libGL qt6-qtbase qt6-qtsvg \
  tbb

To compile examples, also install:

sudo dnf install -y make cmake gcc-c++ expat-devel zlib-devel qt6-qtbase-devel \
  mesa-libGL-devel mesa-libGLU-devel libX11-devel libXpm-devel libXft-devel \
  libXt-devel libXmu-devel libXrender-devel
AlmaLinux 10

Runtime dependencies:

sudo dnf install -y 'dnf-command(config-manager)'
sudo dnf config-manager --set-enabled crb
sudo dnf install -y --allowerasing \
  ca-certificates curl gzip tar expat \
  sqlite-libs zlib libX11 libXext libXmu \
  libXt mesa-libEGL mesa-libGL qt6-qtbase qt6-qtsvg \
  tbb

To compile examples, also install:

sudo dnf install -y make cmake gcc-c++ expat-devel zlib-devel qt6-qtbase-devel \
  mesa-libGL-devel mesa-libGLU-devel libX11-devel libXpm-devel libXft-devel \
  libXt-devel libXmu-devel libXrender-devel
Ubuntu 24.04/26.04

Runtime dependencies:

sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata \
  ca-certificates curl gzip tar libexpat1 \
  libsqlite3-0 zlib1g libegl1 libgl1 libx11-6 \
  libxext6 libxmu6 libxt6 libqt6core6t64 libqt6gui6 \
  libqt6widgets6 libqt6opengl6 libqt6openglwidgets6 libqt6svg6 libtbb12

To compile examples, also install:

sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  make cmake g++ libexpat1-dev zlib1g-dev qt6-base-dev libqt6opengl6 \
  libqt6openglwidgets6 qt6-base-dev-tools libgl1-mesa-dev libglu1-mesa-dev \
  libx11-dev libxpm-dev libxft-dev libxt-dev libxmu-dev libxrender-dev
Debian 13

Runtime dependencies:

sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata \
  ca-certificates curl gzip tar libexpat1 \
  libsqlite3-0 zlib1g libegl1 libgl1 libx11-6 \
  libxext6 libxmu6 libxt6 libqt6core6t64 libqt6gui6 \
  libqt6widgets6 libqt6opengl6 libqt6openglwidgets6 libqt6svg6 libtbb12

To compile examples, also install:

sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  make cmake g++ libexpat1-dev zlib1g-dev qt6-base-dev libqt6opengl6-dev \
  libqt6openglwidgets6 qt6-base-dev-tools libgl1-mesa-dev libglu1-mesa-dev \
  libx11-dev libxpm-dev libxft-dev libxt-dev libxmu-dev libxrender-dev
Arch Linux latest

Runtime dependencies:

sudo pacman-key --init && sudo pacman-key --populate
sudo pacman -Sy --noconfirm archlinux-keyring
sudo pacman -Syu --noconfirm --needed \
  ca-certificates curl gzip tar expat \
  sqlite zlib libx11 libxext libxmu \
  libxt mesa qt6-base qt6-svg tbb

To compile examples, also install:

sudo pacman -Syu --noconfirm --needed make cmake gcc expat zlib qt6-base \
  mesa glu libx11 libxpm libxft libxt libxmu libxrender
macOS 26 (Apple Silicon)

Runtime dependencies:

brew install qt
brew install --cask xquartz

To compile examples, also install:

xcode-select --install
brew install cmake

Step 2. Download the archive

Open the assets in the development release and select the archive for your platform. Linux filenames include the distribution and release; use the matching OS from the supported-images table. The debug image has no binary archive. The macOS archive is built for macOS 26 on Apple Silicon; its filename also includes the compiler version used by CI.

Platform Archive filename pattern
Linux geant4-<version>-<distribution>-<release>-<arch>.tar.gz
macOS geant4-<version>-macosx26-clang<major>-arm64.tar.gz

Check your CPU with uname -m: x86_64 maps to Linux archive suffix amd64; aarch64 and arm64 map to arm64. Arch Linux archives are available for amd64 only.

For example, download the Ubuntu 24.04 archive for amd64 below. On another platform, replace archive with the exact filename from the release assets before running curl.

archive="geant4-11.4.3-ubuntu-24.04-amd64.tar.gz"
curl -fL -o "$archive" "https://github.com/gemc/g4install/releases/download/dev/$archive"

Step 3. Extract and activate the installation

Extract the archive into an empty directory, install the Geant4 datasets, and source the generated environment file:

mkdir -p "$HOME/geant4-11.4.3"
tar -xzf "$archive" \
  -C "$HOME/geant4-11.4.3" --strip-components=1
cd "$HOME/geant4-11.4.3"
./install_geant4_data.sh
source ./geant4.env
geant4-config --version

Dataset installation downloads several gigabytes; set GEANT4_DATA_BASE_URL only when using an approved mirror.


Open a new terminal

According to the installation, follow these instructions to open a new terminal with the Geant4 environment.

Source installation

On macOS with Z shell (change it for bash), initialize Homebrew's module package first if needed. I suggest you add these to your .rc file.

export MODULESHOME="$(brew --prefix modules)"
source "$MODULESHOME/init/zsh"

After Environment Modules is initialized, register the modulefiles and load Geant4 again:

module use "$HOME/g4install/modules"
module load geant4/11.4.3
geant4-config --version

Add the appropriate initialization and module use commands to your shell configuration, in that order, to make them available in future terminals.

Binary installation

Source the environment from the directory where you extracted the archive:

source "$HOME/geant4-11.4.3/geant4.env"
geant4-config --version

The downloaded datasets remain installed; you do not need to download them again for each terminal.

Docker

Run the same container command again with the same host-directory mount:

docker run --rm -it \
  -v "$HOME/mywork:/work" -w /work \
  -p 6080:6080 -p 5900:5900 \
  -e X11VNC_PASSWORD=change-me \
  -e VNC_BIND=0.0.0.0 \
  -e GEOMETRY=1920x1200 \
  ghcr.io/gemc/g4install:11.4.3-ubuntu-24.04

Your files reappear under /work. For visualization, use the noVNC command from the Docker installation section with the same mount instead.


Compile and run a Geant4 example

Open a new terminal according to your installation.

Step 1. Compile B5

Compile the bundled B5 example in a separate build directory:

cmake -S "$G4INSTALL/share/Geant4/examples/basic/B5" -B build_B5 \
  -DCMAKE_PREFIX_PATH="$G4INSTALL;$CLHEP_BASE_DIR;$XERCESCROOT"
cmake --build build_B5 --parallel 4

Step 2. Run in batch mode

Run from the build directory so B5 can find the macros copied there by CMake:

cd build_B5
./exampleB5 run1.mac

The macro runs four short simulations with three events each, then returns to the shell. Successful output includes event summaries and writes ROOT analysis files in the build directory.

Step 3. Run interactively with visualization

From the same build directory, start B5 without a macro argument:

./exampleB5

This opens the visualization interface. Enter /run/beamOn 3 in its command prompt to simulate three events. A source or binary installation needs a graphical session; on macOS, start XQuartz for X11 viewers. With Docker, use a terminal inside the noVNC desktop started in Step 1. AlmaLinux 10 supports batch mode only.

Switching Geant4 versions

For source installations, installed versions coexist in separate directories. The example below assumes both versions are installed. Use explicit old and new module names when switching:

module load geant4/11.3.2

module switch geant4/11.4.3

module switch geant4/hello-dev

Troubleshooting

module: command not found

Start a new login shell after installing Environment Modules. If the command is still unavailable, initialize the package explicitly using the path supplied by your distribution or Homebrew.

module avail geant4 shows nothing

Register the repository's modules directory, not the repository root:

module use "$HOME/g4install/modules"
module avail geant4

The wrong Geant4 version is active

Reset the module environment and load the desired version:

module purge
module use "$HOME/g4install/modules"
module load geant4/11.4.3
module list
geant4-config --version

Supported Geant4 versions are defined in ci/env.sh by supported_g4_versions; put the default version first. The generator uses that version in the installation examples and renders image tables for every supported version. Runtime package lists come from ci/binary_packages.py.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages