Geant4 User's Guide
For Application Developers Getting Started with Geant4 |
2.7 How to Make an Executable Program
2.7.1 Building ExampleN01 in a UNIX Environment
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.
architecture.gmk | invoking and defining all the architecture specific settings and paths
which are stored in $G4INSTALL/config/sys.
common.gmk
| defining all general GNUmake rules for building objects and libraries
| globlib.gmk
| defining all general GNUmake rules for building compound libraries
| binmake.gmk
| defining the general GNUmake rules for building executables
| GNUmakefile
| placed inside each directory in the Geant4 distribution and defining
directives specific to build a library, a set of sub-libraries, or an executable.
| |
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".
> cd $G4WORKDIR/examples/novice/N01 > gmakeThis 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.