12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Getting Started with <strong>Geant4</strong>- Running a Simple Example2.7. How to Make an Executable Program2.7.1. Building ExampleN01 in a UNIX EnvironmentThe code <strong>for</strong> the user examples in <strong>Geant4</strong> is placed in the directory $G4INSTALL/examples, where$G4INSTALL is the environment variable set to the place where the <strong>Geant4</strong> distribution is installed (set by defaultto $HOME/geant4). In the following sections, a quick overview on how the GNUmake mechanism works in<strong>Geant4</strong> will be given, and we will show how to build a concrete example, "ExampleN01", which is part of the<strong>Geant4</strong> distribution.2.7.1.1. How GNUmake works in <strong>Geant4</strong>The GNUmake process in <strong>Geant4</strong> is mainly controlled by the following GNUmake script files (*.gmk scriptsare placed in $G4INSTALL/config):architecture.gmkinvoking and defining all the architecture specific settings and paths which are stored in $G4INSTALL/config/sys.common.gmkdefining all general GNUmake rules <strong>for</strong> building objects and librariesgloblib.gmkdefining all general GNUmake rules <strong>for</strong> building compound librariesbinmake.gmkdefining the general GNUmake rules <strong>for</strong> building executablesGNUmakefileplaced inside each directory in the <strong>Geant4</strong> distribution and defining directives specific to build a library, aset of sub-libraries, or an executable.Kernel libraries are placed by default in $G4INSTALL/lib/$G4SYSTEM, where $G4SYSTEM specifies thesystem 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 <strong>for</strong> <strong>Geant4</strong> in the user area.For more in<strong>for</strong>mation on how to build <strong>Geant4</strong> kernel libraries and set up the correct environment <strong>for</strong> <strong>Geant4</strong>, referto the "Installation <strong>Guide</strong>".2.7.1.2. Building the executableThe compilation process to build an executable, such as an example from $G4INSTALL/examples, is startedby invoking the "make" command from the (sub)directory in which you are interested. To build, <strong>for</strong> 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> gmakeThis will create, in $G4WORKDIR/bin/$G4SYSTEM, the "exampleN01" executable, which you can invoke andrun. You should actually add $G4WORKDIR/bin/$G4SYSTEM to $PATH in your environment.2.7.2. Building ExampleN01 in a Windows EnvironmentThe procedure to build a <strong>Geant4</strong> executable on a system based on a Windows system is similar to what should bedone on a UNIX based system, assuming that your system is equipped with GNUmake, MS-Visual C++ compilerand the required software to run <strong>Geant4</strong> (see "Installation <strong>Guide</strong>").18

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!