2.3.  Installing Geant4 Manually

Before proceeding with the installation, some key environment variables must be defined in your user environment in order to specify where all software components are to be placed and to set some compilation options. A complete reference to all environment variables in Geant4 is available in section Appendix - Makefiles and Environment Variables of the Geant4 User's Guide for Application Developers .

2.3.1.  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

2.3.2.  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 make includes (default in $G4INSTALL/include)

G4DEBUG:

flag specifying that libraries be built with debug symbols (requires a lot of disk space). The default is optimised-mode

G4LIB_BUILD_SHARED:

flag specifying that kernel libraries be built as shared libraries (libraries will then be used by default). If not set, static archive libraries are built by default

G4LIB_BUILD_STATIC:

flag specifying that kernel libraries be built as static archive libraries. Note that you may specify this flag in addition to G4LIB_BUILD_SHARED to build shared and static libraries simultaneously.

G4LIB_BUILD_G3TOG4:

flag specifying that the library for the g3tog4 module be built. By default the library will not be built.

G4LIB_BUILD_ZLIB:

flag specifying that an additional library for file compression should be built (not required on Linux/Unix systems, required on Windows if choosing OpenGL or OpenInventor visualization). By default the library will not be built.

G4_NO_VERBOSE:

defining this flag prevents the compilation of verbosity code (for better performance). The default is with verbosity on.

The list of all additional flags (also requiring third-party packages installed) can be found in Section 5.2 of the Geant4 User's Guide for Application Developers .

The Geant4 installation requires native STL (the Standard Template Library) as the base foundation class library. This also implies strict ISO-ANSI language compliance. In addition to the above, you might want to set the proper environment for visualization, such as:

  • the kind of graphics driver(s) installed in the system

  • the path to the installation of each graphics driver

in case you want to build the Geant4 kernel libraries with the graphics drivers built-in. See Visualization - The Visualization Drivers of the Geant4 User's Guide for Application Developers .

At this point, you may choose one of two ways to compile and install the kernel libraries, depending on your needs and system resources. From $G4INSTALL/source:

  1. make

    This will make one library for each "leaf" category (maximum library granularity) and automatically produce a map of library use and dependencies.

  2. make global

    This will make global libraries, one for each major category.

The main advantage of the first approach is the speed of building the libraries and of the application, which in some cases can be improved by a factor of two or three compared to the "global library" approach.

Using the "granular library" approach a fairly large number (roughly 90) of "leaf" libraries is produced. However, the dependencies and linking list are 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 make libmap issued from $G4INSTALL/source, allows manual rebuilding of 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 "make" and "make 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.