source: trunk/Documentation/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch02s07.html @ 901

Last change on this file since 901 was 901, checked in by garnier, 16 years ago

Add Geant4 Documentation at 8.12.2008

File size: 7.3 KB
Line 
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>2.7.  How to Make an Executable Program</title><link rel="stylesheet" href="../xml/XSLCustomizationLayer/G4HTMLStylesheet.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.71.1"><link rel="start" href="index.html" title="Geant4 User's Guide for Application Developers"><link rel="up" href="ch02.html" title="Chapter 2.  Getting Started with Geant4 - Running a Simple Example"><link rel="prev" href="ch02s06.html" title="2.6.  How to Generate a Primary Event"><link rel="next" href="ch02s08.html" title="2.8.  How to Set Up an Interactive Session"><script language="JavaScript">
2function remote_win(fName)
3{
4   var url = "AllResources/Detector/geometry.src/" + fName;
5   RemoteWin=window.open(url,"","resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,copyhistory=0,width=520,height=520")
6   RemoteWin.creator=self
7}
8</script></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.7. 
9How to Make an Executable Program
10</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02s06.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><th width="60%" align="center">Chapter 2. 
11Getting Started with Geant4 - Running a Simple Example
12</th><td width="20%" align="right"> <a accesskey="n" href="ch02s08.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect.HowToMakeExec"></a>2.7. 
13How to Make an Executable Program
14</h2></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToMakeExec.UNIX"></a>2.7.1. 
15Building ExampleN01 in a UNIX Environment
16</h3></div></div></div><p>
17The code for the user examples in Geant4 is placed in the directory
18<code class="literal">$G4INSTALL/examples</code>, where <code class="literal">$G4INSTALL</code> is the
19environment variable set to the place where the Geant4 distribution
20is installed (set by default to <code class="literal">$HOME/geant4</code>). In the
21following sections, a quick overview on how the GNUmake mechanism
22works in Geant4 will be given, and we will show how to build a
23concrete example, "ExampleN01", which is part of the Geant4
24distribution.
25</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.HowToMakeExec.UNIX.HowGNUmakeWorks"></a>2.7.1.1. 
26How GNUmake works in Geant4
27</h4></div></div></div><p>
28The GNUmake process in Geant4 is mainly controlled by the following
29GNUmake script files (<code class="literal">*.gmk</code> scripts are placed in
30<code class="literal">$G4INSTALL/config</code>):
31
32</p><div class="variablelist"><dl><dt><span class="term"><code class="literal">architecture.gmk</code></span></dt><dd>
33    invoking and defining all the architecture specific settings
34    and paths which are stored in <code class="literal">$G4INSTALL/config/sys</code>.
35    </dd><dt><span class="term"><code class="literal">common.gmk</code></span></dt><dd>
36    defining all general GNUmake rules for building objects and libraries
37    </dd><dt><span class="term"><code class="literal">globlib.gmk</code></span></dt><dd>
38    defining all general GNUmake rules for building compound libraries
39    </dd><dt><span class="term"><code class="literal">binmake.gmk</code></span></dt><dd>
40    defining the general GNUmake rules for building executables
41    </dd><dt><span class="term"><code class="literal">GNUmakefile</code></span></dt><dd>
42    placed inside each directory in the Geant4 distribution and defining
43    directives specific to build a library, a set of sub-libraries, or
44    an executable.
45    </dd></dl></div><p>
46</p><p>
47Kernel libraries are placed by default in
48<code class="literal">$G4INSTALL/lib/$G4SYSTEM</code>, where <code class="literal">$G4SYSTEM</code>
49specifies the system architecture and compiler in use. Executable
50binaries are placed in <code class="literal">$G4WORKDIR/bin/$G4SYSTEM</code>, and
51temporary files (object-files and data products of the compilation
52process) in <code class="literal">$G4WORKDIR/tmp/$G4SYSTEM</code>. <code class="literal">$G4WORKDIR</code>
53(set by default to <code class="literal">$G4INSTALL</code>) should be set by the user
54to specify the place his/her own workdir for Geant4 in the user
55area.
56</p><p>
57For more information on how to build Geant4 kernel libraries and
58set up the correct environment for Geant4, refer to the
59"Installation Guide".
60</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.HowToMakeExec.UNIX.BuildExec"></a>2.7.1.2. 
61Building the executable</h4></div></div></div><p>
62The compilation process to build an executable, such as an example
63from <code class="literal">$G4INSTALL/examples</code>, is started by invoking the
64"gmake" command from the (sub)directory in which you are
65interested. To build, for instance, exampleN01 in your
66<code class="literal">$G4WORKDIR</code> area, you should copy the module
67<code class="literal">$G4INSTALL/examples</code> to your <code class="literal">$G4WORKDIR</code> 
68and do the following actions:
69
70</p><div class="informalexample"><pre class="programlisting">
71  &gt; cd $G4WORKDIR/examples/novice/N01
72  &gt; gmake
73</pre></div><p>
74</p><p>
75This will create, in <code class="literal">$G4WORKDIR/bin/$G4SYSTEM</code>, the
76"exampleN01" executable, which you can invoke and run. You should
77actually add <code class="literal">$G4WORKDIR/bin/$G4SYSTEM</code> to
78<code class="literal">$PATH</code> in your environment.
79</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToMakeExec.Windows"></a>2.7.2. 
80Building ExampleN01 in a Windows Environment
81</h3></div></div></div><p>
82The procedure to build a Geant4 executable on a system based on a
83Windows system is similar to what should be done on a UNIX based
84system, assuming that your system is equipped with GNUmake,
85MS-Visual C++ compiler and the required software to run Geant4 (see
86"Installation Guide").
87</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.HowToMakeExec.Windows.BuildExec"></a>2.7.2.1. 
88Building the executable
89</h4></div></div></div><p>
90See paragraph <a href="ch02s07.html#sect.HowToMakeExec.UNIX" title="2.7.1. 
91Building ExampleN01 in a UNIX Environment
92">Section 2.7.1</a>.
93</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02s06.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><td width="20%" align="center"><a accesskey="u" href="ch02.html"><img src="AllResources/IconsGIF/up.gif" alt="Up"></a></td><td width="40%" align="right"> <a accesskey="n" href="ch02s08.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">2.6. 
94How to Generate a Primary Event
95 </td><td width="20%" align="center"><a accesskey="h" href="index.html"><img src="AllResources/IconsGIF/home.gif" alt="Home"></a></td><td width="40%" align="right" valign="top"> 2.8. 
96How to Set Up an Interactive Session
97</td></tr></table></div></body></html>
Note: See TracBrowser for help on using the repository browser.