Chapter 3.  Setting Up and Using an Install of Geant4

3.1.  Geant4 Installation Locations

If you choose the default installation paths, then your install of Geant4 is completely contained under the directory you chose for CMAKE_INSTALL_PREFIX, with the structure

    +- CMAKE_INSTALL_PREFIX
       +- bin/
       |  +- geant4-config   (UNIX ONLY)
       |  +- geant4.csh      (UNIX ONLY)
       |  +- geant4.sh       (UNIX ONLY)
       |  +- G4global.dll    (WINDOWS ONLY)
       |  +- ...
       +- include/
       |  +- Geant4/
       |     +- G4global.hh
       |     +- ...
       |     +- CLHEP/       (WITH INTERNAL CLHEP ONLY)
       |     +- tools/
       +- lib/               (MAY BE lib64 on LINUX)
       |  +- libG4global.so  (AND/OR .a, OR G4Global.lib ON WINDOWS)
       |  +- ...
       |  +- Geant4-10.3.0/
       |     +- Geant4Config.cmake
       |     +- Geant4ConfigVersion.cmake
       |     +- Geant4LibraryDepends.cmake
       |     +- Geant4LibraryDepends-Release.cmake
       |     +- UseGeant4.cmake
       |     +- Linux-g++    (OR Darwin-g++ UNIX ONLY SOFTLINK -> ..)
       |     +- Modules/
       +- share
          +- Geant4-10.3.0
             +- geant4-10.3.0
             +- data/        (IF GEANT4_INSTALL_DATA WAS SET)
             +- examples/
             +- geant4make/
                +- geant4make.csh
                +- geant4make.sh
                +- config/
  

If you wish to make the Geant4 binaries and libraries available via your PATH and library path (LD_LIBRARY_PATH on Linux, DYLD_LIBRARY_PATH on OS X), together with default environment variables for locating datasets, you should source the relevant script in CMAKE_INSTALL_PREFIX/bin. Please note that on OS X 10.11 (El Capitan) and higher, DYLD_LIBRARY_PATH is not propagated to programs started under such a shell. This should not affect general running of Geant4 applications as CMake should link and install the libraries with suitable RPATHs on OS X.

On interactive bourne shells (e.g. bash), do (assuming you are in CMAKE_INSTALL_PREFIX/bin):

    $ . geant4.sh
  

This command can also be used to setup the Geant4 environment in other Bourne shell scripts. You can also supply the full path to the script rather than changing to the directory containing it.

On interactive C shells, do (assuming you are in CMAKE_INSTALL_PREFIX/bin):

    $ source geant4.csh
  

In an interactive session you can also supply the full path to the script rather than changing to the directory containing it. The C shell script cannot be sourced directly inside other shell scripts due to a limitation of the C shell which prevents the script being able to locate itself. If you need to source the C shell script inside another, then you can use the command

    cd CMAKE_INSTALL_PREFIX/bin ; source geant4.csh
  

where you should replace CMAKE_INSTALL_PREFIX/bin with the directory you installed geant4.csh in. You can also use the command

    source CMAKE_INSTALL_PREFIX/bin/geant4.csh CMAKE_INSTALL_PREFIX/bin
  

where as above you should replace CMAKE_INSTALL_PREFIX/bin with the directory where geant4.csh is located.

In addition to shell scripts, a modulefile for the Environment Modules system is provided at CMAKE_INSTALL_PREFIX/share/Geant4-10.3.0/geant4-10.3.0. Use of this modulefile will depend on how you use Environment Modules on your system. If you have a private install of Geant4, you can simply copy CMAKE_INSTALL_PREFIX/share/Geant4-10.3.0/geant4-10.3.0 to $HOME/privatemodules/geant4-10.3.0. Here, $HOME/privatemodules is the standard location supported by Environment Modules for personal modulefiles. Geant4 may then be configured using the standard module commands:

    $ module load use.own
    $ module load geant4-10.3.0
  

If you are integrating Geant4 as a system wide tool using Environment Modules as the configuration system, the modulefile may be copied directly to your custom location for modulefiles. You may rename the file if you need to support multiple versions. Paths in the modulefile are absolute to permit such copying, but can be patched if you require relative (to the modulefile or other location) paths. We do not provide tools to perform such operations due to the variety of filesystem hierarchies used to manage tools under Environment Modules.

On Windows, you should add the directory containing the Geant4 dll files to your PATH environment variable. On Windows 7, this can be done via the Control Panel as follows

  1. Open the Windows Control Panel.

  2. Open the System item in the Control Panel.

  3. Click on the Advanced system settings link on the System window (on Windows XP, click on the Advanced tab).

  4. Click on the Environment Variables button in the System Properties window.

  5. Select the PATH entry in the User variables list, and click the Edit button. If PATH is not present, click on the New and create it.

  6. In the popup Edit User Variable window, append the directory in which the Geant4 dlls are installed to the Variable value entry of the PATH variable (Note that on Windows, path entries are separated by semicolons). It's very important to append the Geant4 dll path if you have an existing PATH, otherwise other programs may stop working correctly! If the Variable value entry of the PATH variable is empty, or you've just created it, you can simply set the value to the directory in which the Geant4 dlls are installed. Once you have edited, click OK.