source: trunk/documents/UserDoc/UsersGuides/ForApplicationDeveloper/html/Appendix/tipsCompilation.html @ 1208

Last change on this file since 1208 was 1208, checked in by garnier, 15 years ago

CVS update

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