| 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">
|
|---|
| 2 | function 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.
|
|---|
| 9 | How 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.
|
|---|
| 11 | Getting 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.
|
|---|
| 13 | How 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.
|
|---|
| 15 | Building ExampleN01 in a UNIX Environment
|
|---|
| 16 | </h3></div></div></div><p>
|
|---|
| 17 | The 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
|
|---|
| 19 | environment variable set to the place where the Geant4 distribution
|
|---|
| 20 | is installed (set by default to <code class="literal">$HOME/geant4</code>). In the
|
|---|
| 21 | following sections, a quick overview on how the GNUmake mechanism
|
|---|
| 22 | works in Geant4 will be given, and we will show how to build a
|
|---|
| 23 | concrete example, "ExampleN01", which is part of the Geant4
|
|---|
| 24 | distribution.
|
|---|
| 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.
|
|---|
| 26 | How GNUmake works in Geant4
|
|---|
| 27 | </h4></div></div></div><p>
|
|---|
| 28 | The GNUmake process in Geant4 is mainly controlled by the following
|
|---|
| 29 | GNUmake 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>
|
|---|
| 47 | Kernel libraries are placed by default in
|
|---|
| 48 | <code class="literal">$G4INSTALL/lib/$G4SYSTEM</code>, where <code class="literal">$G4SYSTEM</code>
|
|---|
| 49 | specifies the system architecture and compiler in use. Executable
|
|---|
| 50 | binaries are placed in <code class="literal">$G4WORKDIR/bin/$G4SYSTEM</code>, and
|
|---|
| 51 | temporary files (object-files and data products of the compilation
|
|---|
| 52 | process) 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
|
|---|
| 54 | to specify the place his/her own workdir for Geant4 in the user
|
|---|
| 55 | area.
|
|---|
| 56 | </p><p>
|
|---|
| 57 | For more information on how to build Geant4 kernel libraries and
|
|---|
| 58 | set 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.
|
|---|
| 61 | Building the executable</h4></div></div></div><p>
|
|---|
| 62 | The compilation process to build an executable, such as an example
|
|---|
| 63 | from <code class="literal">$G4INSTALL/examples</code>, is started by invoking the
|
|---|
| 64 | "gmake" command from the (sub)directory in which you are
|
|---|
| 65 | interested. 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>
|
|---|
| 68 | and do the following actions:
|
|---|
| 69 |
|
|---|
| 70 | </p><div class="informalexample"><pre class="programlisting">
|
|---|
| 71 | > cd $G4WORKDIR/examples/novice/N01
|
|---|
| 72 | > gmake
|
|---|
| 73 | </pre></div><p>
|
|---|
| 74 | </p><p>
|
|---|
| 75 | This will create, in <code class="literal">$G4WORKDIR/bin/$G4SYSTEM</code>, the
|
|---|
| 76 | "exampleN01" executable, which you can invoke and run. You should
|
|---|
| 77 | actually 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.
|
|---|
| 80 | Building ExampleN01 in a Windows Environment
|
|---|
| 81 | </h3></div></div></div><p>
|
|---|
| 82 | The procedure to build a Geant4 executable on a system based on a
|
|---|
| 83 | Windows system is similar to what should be done on a UNIX based
|
|---|
| 84 | system, assuming that your system is equipped with GNUmake,
|
|---|
| 85 | MS-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.
|
|---|
| 88 | Building the executable
|
|---|
| 89 | </h4></div></div></div><p>
|
|---|
| 90 | See paragraph <a href="ch02s07.html#sect.HowToMakeExec.UNIX" title="2.7.1.
|
|---|
| 91 | Building 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.
|
|---|
| 94 | How 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.
|
|---|
| 96 | How to Set Up an Interactive Session
|
|---|
| 97 | </td></tr></table></div></body></html>
|
|---|