Overview Contents Previous Next

Installation Guide



2. Installation procedures




To install Geant4, you need to have already pre-installed on your system the required software listed in sections 1.2 and 1.3 (in case of graphics drivers) of this Installation Guide.

In this section, a short tutorial on how to install the toolkit's kernel libraries will be given. The installation of the Geant4 kernel libraries and the proper configuration of the environment can be achieved either manually (by setting the proper environment variables) or through the Configure shell script.

2.1 Installing Geant4 manually

Before proceeding with the installation, you need to define some key environment variables in your user environment, in order to specify where all software components are placed and to set some compilation options.A complete reference to all environment variables in Geant4 is available in section 10.5 of the "User's Guide - For Application Developers".

Required Environment Variables

G4SYSTEM:
set to one of the flavors listed in section 1.1 to specify the kind of architecture and compiler used
G4INSTALL:
path where the Geant4 toolkit tree is installed (ex. $HOME/geant4)
CLHEP_BASE_DIR:
path to the CLHEP installation

Optional Environment Variables

G4WORKDIR:
path of the user's working directory (default in $G4INSTALL)
G4LIB:
path where the kernel libraries should be installed (default in $G4INSTALL/lib)
G4TMP:
path where temporary files (object files, dependency files) are placed (default in $G4WORKDIR/tmp)
G4BIN:
path where final executable files are placed (default in $G4WORKDIR/bin).
G4INCLUDE:
path where source header files may be mirrored at installation by issuing gmake includes (default in $G4INSTALL/include)
G4DEBUG:
flag specifying to build libraries with debug symbols (needs a lot of disk space). The default is optimised-mode
G4LIB_BUILD_SHARED:
flag specifying to build kernel libraries as shared libraries (libraries will be then used by default). If not set, static archive libraries are built by default
G4LIB_BUILD_STATIC:
flag specifying to build kernel libraries as static archive libraries. Note that you may specify this flag in addition to G4LIB_BUILD_SHARED to build shared and static libraries simultaneously.
G4USE_G3TOG4:
flag specifying to build the library for the g3tog4 module. By default the library will not be built.
G4_NO_VERBOSE:
verbosity code can be left out from compilation (for better performance) by defining this flag. The default is with verbosity on.
The Geant4 installation scripts select native STL (the Standard Template Library) as base foundation class library. This now requires also strict ISO-ANSI language compliance. In addition to the above, you might want to set the proper environment for visualization, such as: in case you want to build the GEANT4 kernel libraries with the graphics drivers built-in. See Section 8.6 Visualization Drivers in the "User's Guide: For Application Developers". See also $G4INSTALL/source/visualization/README for installation tips.

At this point, do the following to start building the compilation and installation of the kernel libraries.
You can choose to build libraries in one of two ways, according to the needs and system resources. From $G4INSTALL/source:

  1. gmake
    This will make one library for each "leaf" category (maximum library granularity) and produce automatically a map of library use and dependencies.
  2. gmake global
    This will make global libraries, one for each major category.
Advantages of using approach 1. can be noticed mainly concerning the speed of building libraries and the application, which in some cases can be improved also of a factor 2 or 3 compared to the "global library" approach.
Using the "granular library" approach a fairly big number of "leaf" libraries is produced (in the order of 70 libraries), dependencies and linking list are however evaluated and generated automatically on the fly. The top-level GNUmakefile in $G4INSTALL/source parses the dependency files of Geant4 and produces a file libname.map in $G4LIB. libname.map is produced by the tool liblist, whose source code is in $G4INSTALL/config.
When building a binary application the script binmake.gmk in $G4INSTALL/config will parse the user's dependency files and use libname.map to determine through liblist the required libraries to add to the linking list. Only the required libraries will be loaded in the link command.
The command gmake libmap issued from $G4INSTALL/source, allows to manually rebuild the dependency map. The command is issued by default in the normal build process for granular libraries.
It is possible to install both "granular" and "compound" libraries, by typing "gmake" and "gmake global" in sequence. In this case, to choose usage of granular libraries at link time one should set the flag G4LIB_USE_GRANULAR in the environment; otherwise compound libraries will be adopted by default.

2.2 Using the Configure shell script

Since release 3.2 a shell script is provided for easier installation. The Configure shell script is placed in the installation directory $G4INSTALL and allows the user or system administrator to install the Geant4 toolkit in an automatic way. It requires some knowledge of the system from the installer, such as: To run the installer script for installation of the Geant4 Toolkit, one has to type from $G4INSTALL:
 > ./Configure -install
and follow the instructions on-screen. The script provides with default settings for most of the environment variables to be set; by pressing -RETURN-, the default values will be selected, otherwise the proper selection (or path, in case a path is requested) must be typed in.

In case the installation procedure fails for some reason or you realise the selected options were not correct at the time the installation started, you can repeat the whole process by manually removing the current installation with:

 > cd $G4INSTALL/source
 > gmake clean
where $G4SYSTEM and $G4INSTALL are manually set in your environment.

In case new modules must be added to an existing installation (for example a module for visualization), this can either be done manually, by setting the proper environment variables, building the modules and then updating the existing shell script env.csh, or by rerunning Configure in the same installation area and providing the new settings.


2.2.1 Configuring the environment to use Geant4

Once libraries have been installed, the user's environment has to be correctly setup for the usage of the Geant4 toolkit. The Configure script provides a way to check the existing installation and provide the correct configuration for the user's environment. To run the configuration script for configuring the user's environment, the user must type:
 > $G4INSTALL/Configure
to determine and generate the correct shell script env.csh to be sourced or integrated in the shell login script (.tcsh for example). The shell script will be generated by default in the user's current directory ($PWD). The user can customise it to specify for example his/her proper working directory through the variable $G4WORKDIR. Once the generated script is sourced, the user will be ready to start building a Geant4 application.
Refer to section 2.7 of the "Geant4 User's Guide for Application Developers" for information on how to build an executable in Geant4.

2.3 Integrating Geant4 in a generic framework

As part of the Geant4 kernel libraries installation, it is also possible to localise the whole set of header files in a single place, which is determined by the environment variable G4INCLUDE specifying the directory path. Therefore, it's rather straightforward to integrate Geant4 in a generic external framework, by simply knowing the path where header files are located in the system (G4INCLUDE) and where installed libraries are placed (G4LIB).

In section 10.5 of the Appendix, you can find together with the list of all environment variables, also a section explaining how to integrate external libraries which may use or not use Geant4 kernel libraries, in the GNUmake mechanism of Geant4.


About the authors