Appendix .  Appendix

1.  Tips for Program Compilation

This section is dedicated to illustrate and justify some of the options used and fixed by default in the compilation of the Geant4 toolkit. It is also meant to be a simple guide for the user/installer to avoid or overcome problems which may occur on some compilers. Solutions proposed here are based on the experience gained while porting the Geant4 code to different architectures/compilers and are specific to the OS's and compiler's version valid at the current time of writing of this manual.

It's well known that each compiler adopts its own internal techniques to produce the object code, which in the end might be more or less perfomant and more or less optimised, depending on several factors also related to the system architecture which it applies to.

After the installation of the libraries, we strongly suggest to always distinguish between the installation directory (identified by $G4INSTALL) and the working directory (identified by $G4WORKDIR), in order not to alter the installation area.

1.1.  Unix/Linux - g++

OS: Linux

Compiler: GNU/gcc

Strict ISO/ANSI compilation is forced (-ansi -pedantic compiler flags), also code is compiled with high verbosity diagnostics (-Wall flag). The default optimisation level is -O2. The CMake build mode RelWithDebInfo allows for an optimised build of the libraries but including debug symbols (-O2 -g flags on g++, flag G4OPTDEBUG in the GNUMake system).

Note

Additional compilation options (-march=XXX -mfpmath=sseYYY) to adopt chip specific floating-point operations on the SSE unit, can be activated by adapting the XXX, YYY options to your chip and adding these to the CMAKE_CXX_FLAGS variable via ccmake or the CMake GUI (or by uncommenting the relevant part in the Linux-g++.gmk configuration script for the GNUMake system). By doing so, a greater stability of results has been verified, making possible reproducibility of exact outputs between debug, non-optimised and optimised runs. A little performance improvement (in the order of 2%) can also be achieved in some cases. To be considered that binaries built using these chip-specific options will likely NOT be portable cross platforms; generated applications will only run on the specific chip-based architectures.

1.2.  Windows - MS Visual C++

OS: MS/Windows

Compiler: MS-VC++

Since version .NET 7.0 of the compiler, ISO/ANSI compliance is required.

See Section 3.1 of the Installation Guide for more detailed information. See also Section 7.1 for more tips.

1.3.  Mac OS X - g++

OS: Darwin

Compiler: GNU/gcc

The setup adopted for the g++ compiler on Mac OS X resembles in most parts the one for Linux systems.

The default optimisation level in this case is -O2.

Dynamic libraries (.dylib) are supported as well; once built, in order to run the generated application, the user must specify the absolute path in the system where they're installed with the DYLD_LIBRARY_PATH system variable.