KAHIBARO
Discord Login Register

2.1. Geant4 Requirements

C++ compiler

Geant4 is written in C++, so you need a working C++ toolchain before you can build or use it. On most systems this means a compiler plus standard development tools.

Geant4 requires a compiler that supports modern C++ (at least C++11, and in practice usually C++14 or newer). On Linux, the most common choices are GCC and Clang. On recent distributions, the default g++ or clang++ is usually new enough, but very old systems may need an upgrade.

On Debian or Ubuntu based systems, you typically install the compiler and basic tools with a package such as build-essential, which gives you g++, make, and related utilities. On Fedora or other RPM based systems, similar development groups are available. If you rely on a package manager installation of Geant4, these tools might not be strictly required, but they are still very useful for building examples or your own applications.

If you plan to build Geant4 from source, it is important to keep the compiler version consistent between Geant4 and your own applications. Mixing code compiled with very different compiler versions can lead to subtle problems. It is a good habit to use the same compiler executable and version both for the Geant4 build and for your Geant4 based projects.

Some users also install a debugger such as gdb and tools like valgrind for memory checking. These are not formal requirements, but they are extremely helpful when you start developing and debugging your own simulations.

Always use a C++ compiler that supports at least C++11, and build both Geant4 and your applications with the same compiler family and version.

CMake

CMake is the build system generator used by Geant4. It takes CMake configuration files and generates native build files for your platform, for example Makefiles on Linux. You need CMake in two different roles.

First, you need CMake to configure and build Geant4 itself if you choose to build it from source. In this case you run CMake directly in the Geant4 source or build tree. CMake detects your compiler, checks for required libraries, and prepares a build directory.

Second, you use CMake in your own Geant4 applications, through a CMakeLists.txt file in your project. In that file you declare your source files, ask CMake to find Geant4, and tell it how to link your program against the Geant4 libraries. When Geant4 is installed, it provides CMake configuration files that make find_package(Geant4 ...) work in your own project.

You typically install CMake from your distribution packages. The version requirements are modest, but very old CMake releases may not understand some newer CMake commands used by recent Geant4 versions. If CMake is too old, the configuration step will fail early and tell you which minimum version is required.

For beginners, it is important to recognize that CMake is not a compiler. CMake generates the commands that your compiler will execute. You will usually run a sequence such as: create a separate build directory, run cmake there pointing to your source directory, and then run the native build tool (for example make) in the build directory.

CMake is required both to build Geant4 from source and to configure any Geant4 based application through its CMakeLists.txt.

Geant4 data libraries

In addition to C++ code, Geant4 relies on several external physics data libraries. These are collections of tabulated cross sections, energy loss data, decay information, and other physics quantities. At runtime, Geant4 reads these data files to perform accurate simulations.

The data libraries are provided separately from the main Geant4 source code and are versioned together with the Geant4 release. When you install Geant4, either from source or via a package manager, the corresponding data sets must also be installed.

If you build from source, CMake can automatically download and install the required data libraries if you enable the appropriate option during configuration. Alternatively, you can download them manually and tell CMake where they are. After installation, you typically set an environment variable such as G4DATA or several specific variables that point to the directories where the data sets are stored.

At runtime, Geant4 checks these environment variables to locate the data. If they are missing or point to the wrong location, your application may start but then fail when it first needs a specific data set. The error messages usually mention that a given data file cannot be found and name the corresponding environment variable.

Geant4 data libraries must match your Geant4 version, and their locations must be correctly specified through environment variables before running any Geant4 application.

Views: 9

Comments

Please login to add a comment.

Don't have an account? Register now!