The code for the user examples in Geant4 is placed in the directory
$G4INSTALL/examples
, where $G4INSTALL
is the
environment variable set to the place where the Geant4 distribution
is installed (set by default to $HOME/geant4
). In the
following sections, a quick overview on how the GNUmake mechanism
works in Geant4 will be given, and we will show how to build a
concrete example, "ExampleN01", which is part of the Geant4
distribution.
The GNUmake process in Geant4 is mainly controlled by the following
GNUmake script files (*.gmk
scripts are placed in
$G4INSTALL/config
):
architecture.gmk
$G4INSTALL/config/sys
.
common.gmk
globlib.gmk
binmake.gmk
GNUmakefile
Kernel libraries are placed by default in
$G4INSTALL/lib/$G4SYSTEM
, where $G4SYSTEM
specifies the system architecture and compiler in use. Executable
binaries are placed in $G4WORKDIR/bin/$G4SYSTEM
, and
temporary files (object-files and data products of the compilation
process) in $G4WORKDIR/tmp/$G4SYSTEM
. $G4WORKDIR
(set by default to $G4INSTALL
) should be set by the user
to specify the place his/her own workdir for Geant4 in the user
area.
For more information on how to build Geant4 kernel libraries and set up the correct environment for Geant4, refer to the "Installation Guide".
The compilation process to build an executable, such as an example
from $G4INSTALL/examples
, is started by invoking the
"gmake" command from the (sub)directory in which you are
interested. To build, for instance, exampleN01 in your
$G4WORKDIR
area, you should copy the module
$G4INSTALL/examples
to your $G4WORKDIR
and do the following actions:
> cd $G4WORKDIR/examples/novice/N01 > gmake
This will create, in $G4WORKDIR/bin/$G4SYSTEM
, the
"exampleN01" executable, which you can invoke and run. You should
actually add $G4WORKDIR/bin/$G4SYSTEM
to
$PATH
in your environment.
The procedure to build a Geant4 executable on a system based on a Windows system is similar to what should be done on a UNIX based system, assuming that your system is equipped with GNUmake, MS-Visual C++ compiler and the required software to run Geant4 (see "Installation Guide").
See paragraph Section 2.7.1.