| 1 | <HTML>
|
|---|
| 2 | <TITLE>
|
|---|
| 3 | </TITLE>
|
|---|
| 4 |
|
|---|
| 5 | <BODY>
|
|---|
| 6 | <TABLE WIDTH="100%"><TR>
|
|---|
| 7 | <TD>
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 | <A HREF="index.html">
|
|---|
| 11 | <IMG SRC="../../../../resources/html/IconsGIF/Contents.gif" ALT="Contents"></A>
|
|---|
| 12 | <A>
|
|---|
| 13 | <IMG SRC="../../../../resources/html/IconsGIF/PreviousGR.gif" ALT="Previous"></A>
|
|---|
| 14 | <A HREF="histogramming.html">
|
|---|
| 15 | <IMG SRC="../../../../resources/html/IconsGIF/Next.gif" ALT="Next"></A>
|
|---|
| 16 | </TD>
|
|---|
| 17 | <TD ALIGN="Right">
|
|---|
| 18 | <FONT SIZE="-1" COLOR="#238E23">
|
|---|
| 19 | <B>Geant4 User's Guide</B>
|
|---|
| 20 | <BR>
|
|---|
| 21 | <B>For Application Developers</B>
|
|---|
| 22 | <BR>
|
|---|
| 23 | <B>Appendix</B>
|
|---|
| 24 | </FONT>
|
|---|
| 25 | </TD>
|
|---|
| 26 | </TR></TABLE>
|
|---|
| 27 | <BR><BR>
|
|---|
| 28 |
|
|---|
| 29 | <P ALIGN="Center">
|
|---|
| 30 | <FONT SIZE="+3" COLOR="#238E23">
|
|---|
| 31 | <A name="10.1">
|
|---|
| 32 | <B>10.1 Tips for Program Compilation</B></A>
|
|---|
| 33 | </FONT>
|
|---|
| 34 | <BR><BR>
|
|---|
| 35 |
|
|---|
| 36 | <HR ALIGN="Center" SIZE="7%">
|
|---|
| 37 | <BR><BR>
|
|---|
| 38 |
|
|---|
| 39 | <!-- ============================================== Section -->
|
|---|
| 40 |
|
|---|
| 41 | This section is dedicated to illustrate and justify some of the options
|
|---|
| 42 | used and fixed by default in the compilation of the Geant4 toolkit. It
|
|---|
| 43 | is also meant to be a simple guide for the user/installer to avoid or
|
|---|
| 44 | overcome problems which may occur on some compilers. Solutions proposed
|
|---|
| 45 | here are based on the experience gained while porting the Geant4 code
|
|---|
| 46 | to different architectures/compilers and are specific to the OS's and
|
|---|
| 47 | compiler's version valid at the current time of writing of this manual.
|
|---|
| 48 | <P>
|
|---|
| 49 | It's well known that each compiler adopts its own internal techniques
|
|---|
| 50 | to produce the object code, which in the end might be more or less
|
|---|
| 51 | perfomant and more or less optimised, depending on several factors also
|
|---|
| 52 | related to the system architecture which it applies to. A peculiarity
|
|---|
| 53 | of C++ compilers nowadays is the way templated instances are treated
|
|---|
| 54 | during the compilation/linkage process. Some C++ compilers need to
|
|---|
| 55 | store temporarily template instantiation files (object files or
|
|---|
| 56 | temporary source code files) in a "template repository" or directory
|
|---|
| 57 | that can be specified as unique or not directly from the compilation
|
|---|
| 58 | command (probably historically coming from the old cfront-based
|
|---|
| 59 | implementation of the C++ compiler).
|
|---|
| 60 | <P>
|
|---|
| 61 | After the installation of the libraries, we strongly suggest to always
|
|---|
| 62 | distinguish between the installation directory (identified by $G4INSTALL)
|
|---|
| 63 | and the working directory (identified by $G4WORKDIR), in order not to
|
|---|
| 64 | alter the installation area for the template repository.
|
|---|
| 65 | <P>
|
|---|
| 66 | In Geant4, the path to the template repository (for those compilers which
|
|---|
| 67 | make use of it) is specified by the environment variable $G4TREP, which
|
|---|
| 68 | is fixed and points by default to
|
|---|
| 69 | <KBD>$G4WORKDIR/tmp/$G4SYSTEM/g4.ptrepository/</KBD>, where
|
|---|
| 70 | <KBD>$G4SYSTEM</KBD> identifies the system-architecture/compiler
|
|---|
| 71 | currently used and <KBD>$G4WORKDIR</KBD> is the
|
|---|
| 72 | path to the user working directory for Geant4.
|
|---|
| 73 | <P>
|
|---|
| 74 | A secondary template repository <KBD>$G4TREP/exec</KBD> is created by
|
|---|
| 75 | default and
|
|---|
| 76 | can be used when building executables to isolate the main repository
|
|---|
| 77 | used for building the libraries in case of clashes provoked by
|
|---|
| 78 | conflicting class-names. This secondary template repository can be
|
|---|
| 79 | activated by defining in the environment (or in the GNUmakefile related
|
|---|
| 80 | to the test/example to be built) the flag <KBD>G4EXEC_BUILD</KBD>;
|
|---|
| 81 | once activated, the secondary repository will become the read/write one,
|
|---|
| 82 | while the primary repository will be considered read-only.
|
|---|
| 83 | <P>
|
|---|
| 84 | At the current time, only few compilers still make use of a template
|
|---|
| 85 | repository. A good recommendation valid in general such compilers is to
|
|---|
| 86 | make use of a single template repository (specified by the
|
|---|
| 87 | <KBD>$G4TREP</KBD> environment variable) for building all Geant4 libraries;
|
|---|
| 88 | then use a secondary template repository (<KBD>$G4TREP/exec</KBD>, together
|
|---|
| 89 | with the <KBD>$G4EXEC_BUILD</KBD> flag)
|
|---|
| 90 | when building any kind of example or application.<BR>
|
|---|
| 91 | It's always good practise to clean-up the secondary template repository
|
|---|
| 92 | from time to time.
|
|---|
| 93 |
|
|---|
| 94 | <HR>
|
|---|
| 95 | <A name="10.1.3">
|
|---|
| 96 | <H2>10.1.3 Sun</H2></A>
|
|---|
| 97 | <P>
|
|---|
| 98 | OS: SunOS<BR>
|
|---|
| 99 | Compiler: CC<BR>
|
|---|
| 100 | <P>
|
|---|
| 101 | The default optimisation level is <KBD>-O2</KBD>.<BR>
|
|---|
| 102 | Since version 5.0 of the compiler, native-STL is supported and ISO/ANSI
|
|---|
| 103 | compliance is required.
|
|---|
| 104 |
|
|---|
| 105 | <HR>
|
|---|
| 106 | <A name="10.1.4">
|
|---|
| 107 | <H2>10.1.4 Unix/Linux - g++</H2></A>
|
|---|
| 108 | <P>
|
|---|
| 109 | OS: Linux<BR>
|
|---|
| 110 | Compiler: GNU/gcc<BR>
|
|---|
| 111 | <P>
|
|---|
| 112 | Strict ISO/ANSI compilation is forced (<tt>-ansi -pedantic</tt> compiler flags), also
|
|---|
| 113 | code is compiled with high verbosity diagnostics (<tt>-Wall</tt> flag).
|
|---|
| 114 | The default optimisation level is <KBD>-O2</KBD>.<BR>
|
|---|
| 115 | NOTE:<BR>
|
|---|
| 116 | Additional compilation options (<TT>-march=pentium4 -mfpmath=sse</TT>) to adopt
|
|---|
| 117 | Pentium4 chip specific floating-point operations on the SSE unit, can be activated
|
|---|
| 118 | by uncommenting the relevant part in the <TT>Linux-g++.gmk</TT> configuration script.
|
|---|
| 119 | By doing so, it has been verified a greater stability of results, making possible
|
|---|
| 120 | reproducibility of exact outputs between debug, non-optimised and optimised runs.
|
|---|
| 121 | A little performance improvement (in the order of 2%) can also be achieved in some
|
|---|
| 122 | cases. To be considered that binaries built using these chip-specific options will
|
|---|
| 123 | NOT be portable cross platforms; generated applications will only run on Pentium4-based
|
|---|
| 124 | architectures.
|
|---|
| 125 |
|
|---|
| 126 | <HR>
|
|---|
| 127 | <A name="10.1.5">
|
|---|
| 128 | <H2>10.1.5 Windows - MS Visual C++</H2></A>
|
|---|
| 129 | OS: MS/Windows<BR>
|
|---|
| 130 | Compiler: MS-VC++<BR>
|
|---|
| 131 | <P>
|
|---|
| 132 | Since version .NET 7.0 of the compiler, ISO/ANSI compliance is required.<BR>
|
|---|
| 133 | See <A HREF="../../../InstallationGuide/html/PCMachines/pcMachines.html#3.1">section 3.1</A>
|
|---|
| 134 | of the Installation Guide for more detailed information.<BR>
|
|---|
| 135 | See also <A HREF="buildFile.html">section 10.6</A> for more tips.
|
|---|
| 136 |
|
|---|
| 137 | <HR>
|
|---|
| 138 | <A name="10.1.6">
|
|---|
| 139 | <H2>10.1.6 MacOS-X - g++</H2></A>
|
|---|
| 140 | OS: MacOS/Darwin<BR>
|
|---|
| 141 | Compiler: GNU/gcc<BR>
|
|---|
| 142 | <P>
|
|---|
| 143 | The setup adopted for the <TT>g++</TT> compiler on MacOS resembles in
|
|---|
| 144 | great part the one for Linux systems.<BR>
|
|---|
| 145 | The default optimisation level in this case is <KBD>-O2</KBD>.<BR>
|
|---|
| 146 | Dynamic libraries (<TT>.dylib</TT>) are supported as well; once built, in
|
|---|
| 147 | order to run the generated application, the user must specify the absolute
|
|---|
| 148 | path in the system where they're installed with the <TT>DYLD_LIBRARY_PATH</TT>
|
|---|
| 149 | system variable.
|
|---|
| 150 |
|
|---|
| 151 | <HR>
|
|---|
| 152 | <A HREF="../../../../Authors/html/subjectsToAuthors.html">
|
|---|
| 153 | <I>About the authors</I></A>
|
|---|
| 154 |
|
|---|
| 155 | </BODY>
|
|---|
| 156 | </HTML>
|
|---|