You are on page 1of 17

What are the three pieces of software required for building Geant4?

Microsoft Visual C++:

Microsoft C++ is the compiler that is recommended for Geant4 on Windows.

Cygwin:

Cygwin is a Linux shell environment that runs on top of Windows.

While it is possible to run Geant4 without this (see Norman Graf's notes on this, linked from the Geant4 home
page), the officially supported way to run Geant4 on Windows is with Cygwin.

By requiring Cygwin, we obtain a common, Linux-like baseline for all of our users. This greatly simplifies
installation and configuration support.

Cygwin provides essential tools such as the make utility.

Cygwin also provides a C++ compiler, so you may wonder why you also need the Microsoft C++ compiler
mentioned above. The reason is that while the Cygwin compiler does work for Geant4, the Microsoft compiler
produces significantly faster-running code. The Microsoft compiler is therefore the officially supported Geant4
solution.

CLHEP:

CLHEP is a set of base libraries that have long provided great functionality for the particle physics community.
They provide things like matrix manipulations, four-vector tools and lists of particle properties. The Geant4
collaboration has chosen to use these libraries rather than re-invent them. Please note that while CLHEP and
Geant4 both come out of the particle physics communities, they are separate products - the Geant4
collaboration is not responsible for maintenance, distribution or documentation of CLHEP.

Be careful to use only the recommended version of CLHEP. If you use any other version, your code may still
run, but you may get incorrect results.

Getting and Installing Microsoft Visual C++

Microsoft Visual C++ is a component of Microsoft Visual Studio. You can install the entire Microsoft Visual
Studio, or you can install just the component that you need, Visual C++.
Visual C++ is available in a free, stripped-down version that is entirely adequate for Geant4. This version is
called "Visual C++ 2010 Express Edition."
The installation procedure is complicated. I have no idea why Microsoft makes it so difficult.
The Microsoft web pages change very often. If they have changed since the last time this Geant4 installation
guide was updated, you may have to look around the Microsoft pages and use some ingenuity to interpret what
is now the right thing to do.

At present, the free version can be obtained from:

http://www.microsoft.com/express/Downloads
Go there from Internet Explorer rather than some other browser since Internet Explorer can run the installers
directly for you.
The default on the Microsoft download page is the latest version, Visual Studio 2010. The earlier version,
Visual Studio 2008 also works, but we'll use the 2010 version.
Select "Visual C++ 2010 Express" (be sure to select Visual C++, not Visual C#), the select your language.
A message will appear telling you to look at the "Information Bar". Close this message, then do what it says
which is to select "Download File" from the yellow information bar at the top of the window.
You will come to a page that looks exactly like the one you were just on, but it is not exactly the same. Again
select "Visual C++ 2010 Express" (be sure to select Visual C++, not Visual C#), and select your language.
You should now see "File Download - Security Warning".
If you instead see a page titled "Downloads... Thank you for Downloading!", the "File Download - Security
Warning" page is just hidden behind this one. Move the Internet Explorer window to reveal the "File Download
- Security Warning."
In "File Download - Security Warning". Click Run.
It will download a tiny file and then give you another security warning. Again click "Run".
At "Welcome to setup", click "Next".
At "License Terms", click "I have read and accept the license terms" and "Next".
At "Installation Options", unselect the two options, "Silverlight" and "SQL Server" (unless you want them, but
you don't need them for Geant4), then ÔNext".
At "Destination Folder", accept the default and click "Install".
It will download and install about 150 M of code.
Eventually you will get a message telling you to restart your computer to complete the installation. Click
"Restart Now".
When it restarts, it will say "Setup is loading installation components". Just wait.
You will again see "Download and Install Progress" and it will install some more components.
Eventually you will see "Setup complete". Hit "Exit".
Getting and Installing Cygwin
Install Cygwin by downloading setup.exe from
http://www.cygwin.com/
Click where it says "Install it by running setup.exe".
Rather than hitting "Run", hit "Save" and download the setup file to the directory c:\Temp\cygwin
The setup.exe is very quick to download, but it is just a utility that facilitates the main download.
The main download is very time consuming. You are essentially downloading a whole operating system (a
Linux emulator) that runs on top of Windows. Sorry it is so slow. On the plus side, Cygwin provides lots of
useful utilities that you may want to use even without Geant4.
When you do the installation, pay close attention to the notes below. You will be taking the defaults in all but
two cases, but these two exceptions are important, where you specify the need to add the development and
libintl2 packages. Without these packages, Cygwin can only run existing code, not build new code as you must
do.
If you have ever run Cygwin before on this same computer, the setup program may remember your previous
settings rather than the defaults. Check carefully to make sure all settings are as shown below.
Capitilization matters in many parts of installing and running on Windows. So be sure to use upper or lower
case letters exactly as shown below.
Go to your C:\Temp\cygwin directory and run setup.exe
At the Security Warning, hit "Run"
At "Cygwin Net Release Setup Program", hit "Next"
Leave everything set at the defaults for the next few screens, this means:
Installation Type: Install from Internet
Root Directory: c:\cygwin
Install For: All Users
Local Package Directory: c:\Temp\cygwin
Internet Connection: Direct Connection
Choose A Download Site (any one will do)
If the list of download sites does not appear, or if you get other strange behavior from Cygwin, it may be that
your firewall or anti-virus software is blocking Cygwin's work. Some users have reported that temporarily
turning off such software resolved the problem. Don't forget to turn it back on after you have installed Cygwin.
A note from Cygwin on this issue can be found at:
http://cygwin.com/faq/faq-nochunks.html - faq.using.bloda
User URL: leave blank
If you get a message called "Setup Alert" and content about "This is the first time you've installed Cygwin...",
don't worry about it. Just click "OK".
Select Packages: accept all defaults except for the following two changes:
For the Devel category, select Install instead of Default. Do this by clicking just one time on the circle of
arrows next to the word "Devel". It takes a moment to respond, be patient, eventually the word next to the
circle of arrows will change from "Default" to "Install".
For the Libs category, first click the plus sign next to Libs, then just for "libintl2", click on the circle of arrows
to change from "Skip" to "0.12.1-3" (or any other version. Just don't leave it at "Skip").
There are many other useful tools in Cygwin, and you are welcome to include whatever you like, but the
defaults plus the "Devel" and "libintl2" packages is enough for Geant4. You don't have to decide everything
now. You can come back later and rerun setup.exe to pick up these additional tools. The setup application
does a great job of tracking what you already have so that subsequent running only adds what is new.
Select "Next".
You now get a dialog called "Cygwin Setup - Resolving Dependencies". Just accept the defaults and click
"Next". The installation will proceed.
The download will take a long time (but is worthwhile since Cygwin is a great product). After the download
phase is complete, the installation phase begins automatically.
If the installation ends with an error "Postinstall script errors" and somethign about "quilt.sh", ignore it and just
hit "Next".
Finally you will come to a screen that asks whether yo uwant to create Icons. Check the box for "Create iconon
Desktop" and hit "Finish".
Cygwin will create an icon on your desktop. Use this to open a Cygwin window.
The first time you open a Cygwin window, Cygwin will perform some one time setup (it will say things that
start with "Copying skeleton files"). Just let it go ahead.
By default, Cygwin will create a window that doesn't have much scroll back capacity and doesn't support cut
and paste. You can greatly improve this as follows:
Right click on the Cygwin icon and select "Properties"
On the "Options" tab:
Change buffer size to the maximum, 999. This gives you longer command history.
Check "Quick Edit Mode" and "Insert Mode". This makes ctrl-c, ctrl-v work for cutting and pasting.
On the "Layout" tab:
Change "Screen Buffer SizeÉHeight" to the maximum, 9999. This gives longer scroll back.
Change "Window Size" if you want to.
Click "OK".
Getting the Correct Version of Cygwin's make.exe
The latest version of the "make" utility that comes with Cygwin is not compatible with Geant4. Replace it with
an appropriate version by opening a Cygwin window and typing:
cd /usr/bin
mv make.exe make_381.exe
wget http://geant4.cern.ch/support/extras/cygwin/make.exe
chmod +x make.exe
If you're not familiar with "wget", it's a tool to download files from the web without using a full web browser.
It comes as part of the Cygwin web tools package.
Making Cygwin aware of Microsoft Visual C++
Modify C:\cygwin\cygwin.bat to contain the following line (you can use an application like Notepad to edit this
file - don't use Word since it adds additional invisible characters).
Place this line right under where you see:
chdir C:\cygwin\bin
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
Opening a Cygwin window will now give a message like:
Setting environment for using Microsoft Visual Studio 2010 x86 tools.
If you don't see that message when you open a Cygwin window, you do not have Microsoft Visual C++
correctly integrated into your setup. Stop and sort that out before you proceed.
If, for example, you get:
The system cannot find the path specified
The problem is likely just that your particular version of Visual C++ lives in a slightly different directory
(Microsoft is constantly changing these things). Look for a directory that looks roughly like the one mentioned
above and that has a vcvars32.bat. Refer to that directory in your cygwin.bat.
Working in Cygwin Windows
For all of the following, be sure to work within a Cygwin window. Do not use any other kind of command
window, such as the ones from "Command Prompt" or cmd.exe.
Pay close attention to the way you specify the paths to files. Because paths you enter are used by both Geant4
and Windows tools, you need to enter them exactly right. Entering them other ways may seem to work, but
will get you into trouble at later steps.
* Use only forward slash, never backslash
* Always use full path including C: (or other appropriate drive letter)
* Use no spaces in file or directory names
* Use the correct capitilization (upper or lower case letters)
For example, use C:/geant4 but not /geant4 or C:\geant4
Cygwin's responses to you will sometimes use its own notation, such as
/cygdrive/c/geant4
but you should not use that notation yourself. Type everything as in C:/geant4
Six Quick Checks to Avoid the Most Common Problems
Before you go ahead, open a Cygwin window and run the following checks to make sure your environment is
properly configured. Checking these now can save you a lot of trouble later.
Check 1: Make sure Cygwin knows about your Microsoft Visual C++
When you opened the Cygwin window, did you get a message like:
Setting environment for using Microsoft Visual Studio 2010 x86 tools.
If not, review the section above on Making Cygwin aware of Microsoft Visual C++.
Check 2: Make sure you have make:
make is the appropriate command for building code as described below. Users coming from a Linux
background may instead be used to typing gmake. It can be very hard to remember which of these to type, but
if you've done the standard Cygwin installation, only make will be defined.
Type:
which make
You should get:
/usr/bin/make
If you instead get something that starts:
which: no make in ...
it probably means you forgot to ask for the "Devel" part of Cygwin. The default Cygwin installation contains
enough components to run software, but not enough to develop software. Go back to the above instructions
about installing Cygwin, rerun the "setup.exe" utility that you already downloaded, and follow the above
instructions about "Devel". Cygwin does a nice job of remembering what you have already installed and will
not make you download everything all over again.
Check 3: Make sure you have the right version of make:
Type:
make -version
You should get something that starts with:
GNU Make 3.80
If the version is different, review the section above on Getting the Correct Version of Cygwin's make.exe.
Check 4: Make sure you don't have gmake:
Type:
which gmake
You should get:
which: no gmake in ...
If you instead get something that indicates it has found a copy of gmake, the Geant4 build will not work
correctly (a common cause of having gmake is if you have installed MATLAB). A bug in the Geant4
Configure script will cause the Geant4 build will try to use this gmake instead of the correct make and the build
will fail with various strange errors.
This issue will be fixed properly in a new version of the Geant4 Configure script, but for now you need to work
around the problem as follows.
Locate the copy of gmake.exe (the response you got above will tell you where it is).
Rename this copy of gmake.exe to some other name (any name will do).
When you are done with Geant4's ./Configure -build process, you can restore the name back to gmake.exe.
Check 5: Make sure you have an appropriate version of bash:
If you installed your copy of Cygwin recently (any time since Jan of 2009), you can skip this step. If your copy
of Cygwin is older, check to make sure you didn't get a version with a bad copy of the bash environment.
Type:
bash -version
You should get a response something like:
GNU bash, version 3.2.51(24)-release (i686-pc-cygwin)
If the version number is 3.2.25, you will have a problem.
Versions from 3.1 and earlier are OK, and versions from 3.2.48 onwards are OK, but 3.2.25 is bad.
Replace bash.exe by rerunning Cygwin's setup.exe:
Accept the defaults, or make whatever selections you want, until you get to the screen called "Select Packages".
Click on the plus sign next to "Shells".
Click on the circle icon next to "Bash" until it says the above new version number (or something even newer).
Click Next
Cygwin will update only those selections that you have changed since the last time you ran its setup.
Check 6: Make Sure you don't have any unwanted Geant4 Environment Variables:
Unless you're absolutely sure you are starting from a nice clean system, make sure you don't have any pre-
existing Geant4 environment variables. You can use the "printenv" command to show all variables, and filter
this with a "grep" for the string G4 as follows:
From a Cygwin window:
printenv | grep G4
If any variables show up, find out what is setting them and remove them. They might be coming from your
Windows environment setup (see notes above about Settings...Control Panel...System) or from your
cybwin.bat file or from some other script that you invoke upon login for some other project. Take the time now
to find the cause and resolve it.
Getting and Installing CLHEP
Go to the CLHEP source download page:
http://proj-clhep.web.cern.ch/proj-clhep/DISTRIBUTION/clhep.html
From the "Source" section near the bottom of the page, select "clhep-2.1.0.1.tgz"
which corresponds to:
http://proj-clhep.web.cern.ch/proj-clhep/DISTRIBUTION/tarFiles/clhep-2.1.0.1.tgz
The file is about 4 MB.
Put it into:
C:/CLHEP
Depending on your personal settings, Internet Explorer may automatically untar the file, so it may appear as a
.tgz file or as a .tar file.
From a Cygwin window,
navigate to this directory and unpack the file:
cd C:/CLHEP
tar -zxvf clhep-2.1.0.1.tgz
(note that Cygwin includes "tab completion", so you just have to type the first part of the file name and then hit
tab).
The unpacking process will begin, starting with:
2.1.0.1/
2.1.0.1/CLHEP/
2.1.0.1/CLHEP/Cast/
2.1.0.1/CLHEP/Cast/Cast/
2.1.0.1/CLHEP/Cast/Cast/defs.h.in
And ending with:
2.1.0.1/CLHEP/install-sh
2.1.0.1/CLHEP/missing
2.1.0.1/CLHEP/config.sub
2.1.0.1/CLHEP/Makefile.in
2.1.0.1/CLHEP/configure
For the following step, be very careful what you enter for "prefix".
Do NOT forget the two dashes in a row before the word "prefix".
Do NOT use Windows-style path: C:/CLHEP/
Do NOT point at the subdirectory of CLHEP/2.1.0.1 that also happens to be named CLHEP
Run configure as follows:
cd 2.1.0.1/CLHEP
./configure --prefix /cygdrive/c/CLHEP/
You should get a response that starts with:
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking target system type... i686-pc-cygwin
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
And ends with:
config.status: creating test/exctest4.sh
config.status: creating test/exctestNothrow.sh
config.status: creating test/excDblThrow.sh
config.status: creating Exceptions/defs.h
config.status: executing depfiles commands
The complete output from the above command can be found in this same web directory as:
CLHEPConfigure.txt
Remember that for the following you use the utility make, not the one called gmake. The latter is not part of
Cygwin, and if you have it at all, it will an incompatible version that you happen to have from some other
application such as Matlab. See notes above about gmake.
Run the build process by typing:
make
You should get a response that starts with:
Making all in Units
make[1]: Entering directory `/cygdrive/c/CLHEP/2.1.0.1/CLHEP/Units'
Making all in Units
make[2]: Entering directory `/cygdrive/c/CLHEP/2.1.0.1/CLHEP/Units/Units'
make all-am
And ends with:
make[1]: Entering directory `/cygdrive/c/CLHEP/2.1.0.1/CLHEP'
./build-clheplib Units Utility Vector Evaluator GenericFunctions Geometry Random Matrix RandomObjects
Cast RefCount Exceptions
rm -f CLHEP-2.1.0.1.lib
liblist=`./getObjectList -shared Units Utility Vector Evaluator GenericFunctions Geometry Random Matrix
RandomObjects Ca
st RefCount Exceptions`; \lib /NOLOGO /OUT:CLHEP-2.1.0.1.lib $liblist

./build-header
make[1]: Leaving directory `/cygdrive/c/CLHEP/2.1.0.1/CLHEP'
The complete output from the above command can be found in this same web directory as:
CLHEPMake.txt
If you got a response such as:
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... configure: error: cannot compute suffix of executables: cannot compile and
link
See 'config.log' for more details.
configure: error: /bin/sh './configure' failed for Units
It probably means you used the wrong form of path in
./configure --prefix.
Review the notes above.
If you got a response such as:
make[2]: CL: command not found
It probably means you didn't edit your cygwin.bat file properly.
Review the notes above.
If you got a response that mentions missing "cygintl-2.dll":
it probabl means you forgot to tell Cygwin to install "libintl2".
Go back to the above instructions about installing Cygwin, rerun the "setup.exe" utility that you already
downloaded, and follow the above instructions about "libintl2". Cygwin does a nice job of remembering what
you have already installed and will not make you download everything all over again.
Move the build products to their installation area (again, be careful you don't accidentally use gmake - you
need to use make):
make install
You should get a response that starts with:
Making install in Units
make[1]: Entering directory `/cygdrive/c/CLHEP/2.1.0.1/CLHEP/Units'
Making install in Units
make[2]: Entering directory `/cygdrive/c/CLHEP/2.1.0.1/CLHEP/Units/Units'
make[3]: Entering directory `/cygdrive/c/CLHEP/2.1.0.1/CLHEP/Units/Units'
And ends with:
else :; fi
/usr/bin/install -c -m 644 'ClhepVersion.h' '/cygdrive/c/CLHEP//include/CLHEP/C
lhepVersion.h'
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/cygdrive/c/CLHEP/2.1.0.1/CLHEP'
make[1]: Leaving directory `/cygdrive/c/CLHEP/2.1.0.1/CLHEP'
The complete output from the above command can be found in this same web directory as:
CLHEPInstall.txt
You will now have directories such as:
C:/CLHEP/include
and
C:/CLHEP/lib
The exact contents of the lib directory should be as follows (if the files do not end in .lib, you have a problem):
CLHEP-2.1.0.1.lib
CLHEP-Cast-2.1.0.1.lib
CLHEP-Evaluator-2.1.0.1.lib
CLHEP-Exceptions-2.1.0.1.lib
CLHEP-GenericFunctions-2.1.0.1.lib
CLHEP-Geometry-2.1.0.1.lib
CLHEP-Matrix-2.1.0.1.lib
CLHEP-Random-2.1.0.1.lib
CLHEP-RandomObjects-2.1.0.1.lib
CLHEP-RefCount-2.1.0.1.lib
CLHEP-Vector-2.1.0.1.lib
CLHEP.lib
If you have .a files instead of the above .lib files, it may be that you didn't edit your cygwin.bat file properly
and so are using the wrong compiler. Review the notes above.
You're done setting up CLHEP.
If the CLHEP build fails in some strange way, you may be able to instead use pre-built versions of CLHEP. We
do not recommended them in general because they do not work for all versions of Windows or all versions of
C++, but if you have no other solution, this might be the way to solve your issues. Pre-built versions can be
found in the right hand column of the CLHEP source download page:
http://proj-clhep.web.cern.ch/proj-clhep/DISTRIBUTION/clhep.html
Windows users have recently had some success with the version:
i686-winxp-vc9-opt
Untar this with

tar –zxvf i686-winxp-vc9-opt.tar.gz

Move all of its contents (bin, build, include, lib) into C:/CLHEP
If your Geant4 build and run goes OK, then this was an appropriate CLHEP build. If not, then this pre-built
version of CLHEP was not appropriate for your version of Windows or C++.
We do not recommend you run the "make check" command described in the CLHEP documentation unless you
really want to. If you do, note that it will report some errors that you can ignore, such as:
FAIL: testMatrix.sh
FAIL: testInversion.sh
FAIL: testBug6181
Much more detailed instructions on installation of CLHEP are available from the CLHEP web site:
http://proj-clhep.web.cern.ch/proj-clhep/INSTALLATION/newCLHEP-install.html
Getting Geant4
From the Geant4 home page:
http://geant4.web.cern.ch/geant4/
Select "Download" from near the top right corner of the page.
Select "Zip format", which corresponds to:
http://geant4.cern.ch/support/source/geant4_9_4_p01.zip
The file is about 35 M.
Save it to:
cd C:\Geant4
Then use whatever zip extraction tool you like to make the files end up in
C:\Geant4\geant4_9_4_p01
but NOT in:
C:\Geant4\geant4_9_4_p01\geant4_9_4_p01
For example, with Windows Extraction Wizard,
you can just right click on the file, select "Extract All",
tell it to extract files to C:\Geant4
(NOT the default that it offers, which is C:\Geant4\geant4_9_4_p01)
and hit "Next".
Be patient, the extraction process involves a very large number of files.
Getting Data Files
Depending on the physics of your particular application, you may need to install additional data files. These
data files can be downloaded separately from the Geant4 source distribution page (the same place where you
got Geant4 itself).
Create a new folder within C:\Geant4\geant4_9_4_p01 to hold any of these required data files.
C:\Geant4\geant4_9_4_p01\data
For now, pick up the "data files for low energy electromagnetic processes":
http://geant4.cern.ch/support/source/G4EMLOW.6.19.tar.gz
The file is about 14 M.
Put the file into your new data directory.
From a Cygwin window,navigate to this directory and unpack the file:
cd C:/Geant4/geant4_9_4_p01/data
tar -zxvf G4EMLOW.6.19.tar.gz
The unpacking process will begin, starting with:
G4EMLOW6.19/
G4EMLOW6.19/auger/
G4EMLOW6.19/auger/au-tr-pr-10.dat
G4EMLOW6.19/auger/au-tr-pr-100.dat
G4EMLOW6.19/auger/au-tr-pr-11.dat
And ending with:
G4EMLOW6.19/tripdata/pp-trip-cs-95.dat
G4EMLOW6.19/tripdata/pp-trip-cs-96.dat
G4EMLOW6.19/tripdata/pp-trip-cs-97.dat
G4EMLOW6.19/tripdata/pp-trip-cs-98.dat
G4EMLOW6.19/tripdata/pp-trip-cs-99.dat
Doing the Initial Build
TAKE YOUR TIME AT THIS STAGE, DON'T RUSH IT.
Mistakes made at this stage can be very time-consuming to correct. Slow down.
Maybe get a cup of coffee (or a glass of wine) before you proceed. Breathe.
From a Cygwin window:
cd C:/Geant4/geant4_9_4_p01
./Configure -build
You will be asked a series of questions.
In most cases, you can just take the default response (by hitting carriage return).
But pay close attention so that you do not accept the default for certain questions listed below.
If you get an error of the form, "bash: ./Configure: No such file or directory",
it probably means you have a bad copy of the Cygwin bash.exe. See notes on bash above.
Along the way you will see a message "Failed to locate one or more of the Geant4 data libraries..." Don't worry
about this. The additional data libraries are not required for the simple physics in our initial examples. They
can be loaded later as needed. For now, just accept the default response (by hitting carriage return).
When the configure script says:
Could not find CLHEP installed on this system!
Please, specify where CLHEP is installed:
First, confirm that you have installed your CLHEP to
C:/CLHEP
Make sure you have lib, bin and include subdirectories in C:\CLHEP.
If not, recheck your CLHEP installation. If so, proceed.
Enter: C:/CLHEP
Take the default for everything else except:
When it asks about:
Enable building of the WIN32 OpenGL visualization driver? [n]
Enter: y
This tells Geant4 that you want to include the optional OpenGL Visualization driver.
Take the default for everything else.
Once all of the questions have been answered, you will be told:
WARNING: the generated configuration file
can be edited if necessary!
You can introduce any change to the configuration file
/cygdrive/c/Geant4/geant4_9_4_p01/.config/bin/WIN32-VC/config.sh before the final installation.
To do so, use a shell escape now (e.g. !vi /cygdrive/c/Geant4/geant4_9_4_p01/.config/bin/WIN32-
VC/config.sh).
Press [Enter] to start installation or use a shell escape to edit config.sh:
At this point, what you have seen in this question and answer session should match what you find in this web
directory as:
Geant4Build.txt
You are ready to proceed with the build.
Hit Enter.
You will then see:
Now starting Geant4 libraries build...
On this machine the G4SYSTEM=WIN32-VC
On this machine the G4INSTALL=c:/Geant4/geant4_9_4_p01
On this machine the G4TMP=c:/Geant4/geant4_9_4_p01/tmp
On this machine the G4LIB=c:/Geant4/geant4_9_4_p01/lib
On this machine the G4LEVELGAMMADATA=c:/Geant4/geant4_9_4_p01/data/PhotonEvaporation2.1
On this machine the G4RADIOACTIVEDATA=c:/Geant4/geant4_9_4_p01/data/RadioactiveDecay3.3
On this machine the G4LEDATA=c:/Geant4/geant4_9_4_p01/data/G4EMLOW6.19
On this machine the G4NEUTRONHPDATA=c:/Geant4/geant4_9_4_p01/data/G4NDL3.14
On this machine the G4ABLADATA=c:/Geant4/geant4_9_4_p01/data/G4ABLA3.0
On this machine the CLHEP_BASE_DIR=C:/CLHEP
On this machine the CLHEP_INCLUDE_DIR=C:/CLHEP/include
On this machine the CLHEP_LIB_DIR=C:/CLHEP/lib
On this machine the CLHEP_LIB=CLHEP.lib
On this machine G4UI_NONE is not set - following UIs will be built:
On this machine G4VIS_NONE is not set - following drivers will be built:
On this machine the G4VIS_BUILD_OPENGLWIN32_DRIVER=1
On this machine the G4VIS_USE_OPENGLWIN32=1
On this machine the XMFLAGS=
On this machine the XMLIBS=
On this machine the XMFLAGS=
On this machine the XAWFLAGS=
On this machine the XAWLIBS=
On this machine the G4LIB_BUILD_ZLIB=1
On this machine the G4LIB_USE_ZLIB=1
On this machine the G4LIB_BUILD_STATIC=1

Starting build...
Cleaning up /cygdrive/c/Geant4/geant4_9_4_p01/.config/bin/WIN32-VC/g4make.log
Building global libraries...
*************************************************************
Installation Geant4 version - geant4-09-04-patch-01
Copyright (C) 1994-2011 Geant4 Collaboration
*************************************************************
Making dependency for file src/G4ios.cc ...
Making dependency for file src/G4coutDestination.cc ...
Making dependency for file src/G4VStateDependent.cc ...
Making dependency for file src/G4VNotifier.cc ...
Making dependency for file src/G4VExceptionHandler.cc ...
Making dependency for file src/G4UnitsTable.cc ...
Making dependency for file src/G4Timer.cc ...
Making dependency for file src/G4StateManager.cc ...
Making dependency for file src/G4SliceTimer.cc ...
Making dependency for file src/G4Pow.cc ...
Making dependency for file src/G4PhysicsVector.cc ...
Making dependency for file src/G4PhysicsTable.cc ...
Making dependency for file src/G4PhysicsOrderedFreeVector.cc ...
Making dependency for file src/G4PhysicsLogVector.cc ...
Making dependency for file src/G4PhysicsLnVector.cc ...
Making dependency for file src/G4PhysicsLinearVector.cc ...
Making dependency for file src/G4PhysicsFreeVector.cc ...
Making dependency for file src/G4OrderedTable.cc ...
Making dependency for file src/G4LPhysicsFreeVector.cc ...
Making dependency for file src/G4GeometryTolerance.cc ...
Making dependency for file src/G4Exception.cc ...
Making dependency for file src/G4ErrorPropagatorData.cc ...
Making dependency for file src/G4DataVector.cc ...
Making dependency for file src/G4AllocatorPool.cc ...
Removing library libG4globman.a ...
Removing library libG4globman.dll ...
Compiling G4AllocatorPool.cc ...
G4AllocatorPool.cc
Compiling G4DataVector.cc ...
G4DataVector.cc
Compiling G4ErrorPropagatorData.cc ...
G4ErrorPropagatorData.cc
Compiling G4Exception.cc ...
If you get a response such as:
On this machine the G4LIB_BUILD_STATIC=1
On this machine the G4LIB_USE_GRANULAR=1
e:/Geant4/geant4_9_4_p01/config/common.gmk:36: *** target pattern contains no '%'. Stop.
Starting build...
GNUmakefile:108: *** target pattern contains no '%'. Stop.
You probably just have the wrong version of the Cygwin make utility. Reread the section above on Getting the
Correct Version of Cygwin's make.exe. Once you have the correct version of make, clean up your failed
Geant4 build by removing the tmp, lib and bin directories and redo the ./Configure -build.
If you got a response such as:
make[2]: CL: command not found
It probably means that you didn't edit your cygwin.bat file properly and so are using the wrong compiler.
Review the notes above.
If you get a response such as:
process_begin: CreateProcess(NULL, "", ...) failed.
followed by a set of lines such as:
/usr/bin/sh: c:/Program: No such file or directory
It may be that you have the Matlab gmake problem. See notes above.
If you get a response such as:
The syntax of the command is incorrect.
The syntax of the command is incorrect.
'[' is not recognized as an internal or external command,
operable program or batch file.
'[' is not recognized as an internal or external command,
followed by a set of lines such as:
The system cannot find the path specified.
c:\Program Files\MATLAB\R2007a\bin\win32\gmake.exe: *** [banner
It may be that you have the Matlab gmake problem. See notes above.
Once you see any lines like:
Compiling G4AllocatorPool.cc ...
with no errors,
the compilation is successfully under way.
Adjust your machine's power management properties so that it doesn't go to sleep, and then walk away for a
long long time. Wait, and wait, and wait, for the initial compilation to run.
The same information that is showing on the console is also being written to a log file so that you can review it
later if necessary. The information will appear in:
C:/Geant4/geant4_9_4_p01/.config/bin/WIN32=VC
An example of how this log file should look can be found in this same web directory as:
Geant4Make.txt
Eventually, you will see messages stating that libname.map has been built, then you will see messages about
successful completion:
Building library management utility liblist ...
c:/Geant4/geant4_9_4_p01/config/liblist.c:45: warning: `optarg' redeclared without dllimport attribute: previous
dllimpo
rt ignored
c:/Geant4/geant4_9_4_p01/config/liblist.c:46: warning: `optind' redeclared without dllimport attribute: previous
dllimpo
rt ignored
c:/Geant4/geant4_9_4_p01/config/liblist.c:46: warning: `opterr' redeclared without dllimport attribute: previous
dllimpo
rt ignored
c:/Geant4/geant4_9_4_p01/config/liblist.c:46: warning: `optopt' redeclared without dllimport attribute: previous
dllimpo
rt ignored
Libraries installation completed !
####################################################
# Your Geant4 installation seems to be successful!
# To be sure please have a look into the log file:
# /cygdrive/c/Geant4/geant4_9_4_p01/.config/bin/WIN32-VC/g4make.log
####################################################
If you get a response such as:
Libmap stage. Searching for GNUmakefiles and sorting ...
Weeding out paths and files ...
: No such file or directoryfile
: No such file or directoryr/GNUmakefile
: No such file or directoryGNUmakefile
: No such file or directoryement/GNUmakefile
: No such file or directorying/GNUmakefile
Making libname.map ...
Reading library name map file...
ERROR: "source/<unique-sub-path>/GNUmakefile" expected.
make[1]: *** [libmap] Error 1
make: *** [all] Error 2
you probably selected the wrong "Default Text File Type" when you did the Cygwin installation.
Rerun Cygwin's setup.exe and see what it shows for Default Text File Type. It should be Unix /Binary. If it
isn't, then you must have had it wrong last time. Correct that, complete the Cygwin setup, then delete your
CLHEP and Geant4 and start over.
If you get a response that includes:
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\utility(54) : error C2079:
'std::pair<_Ty1,_Ty2>::second' uses undefined class 'G4AttDef'
with
[
_Ty1=const G4String,
_Ty2=G4AttDef
]
É h:/geant4/geant4_9_4_p01/source/graphics_reps/include\G4AttHolder.hh(75) : see reference to class
template instantiation 'std::vector<_Ty>' being compiled with
[
_Ty=const std::map<G4String,G4AttDef> *

make: *** [c:/geant4/tmp/WIN32-VC/G4vis_management/G4VSceneHandler.o] Error 2


you probably have a very old copy of Visual Studio and forgot to include the "SP1" patch.
Update Visual Studio (at least add the SP1 patch), delete your Geant4 lib, bin and tmp and try again.
If you had needed to rename some other application's gmake.exe before your initial ./Configure -buld, you can
safely restore that gmake.exe now.
Single versus Multi-User Installation
The above instructions assumed you were doing a single-user installation. They had you keep all of the build
products in the same area as your CLHEP and Geant4 source. Note however that both of these packages
support standard multi-user installation processes.
For CLHEP, just specify a different value for "--prefix".
When Geant4's ./Configure -build asks you to "Specify the path where Geant4 libraries and source files should
be installed", specify the area you want the code to eventually be installed.
When Geant4's ./Configure -build asks you about the CLHEP library, be sure to specify the same location that
you specified during the CLHEP installation.
After you finish the ./Configure -build, issue an additional command to copy the libraries and header files to the
installation area:
./Configure -install.
Creating the setup script
The configure process has set up some environment variables that you will want to have in future sessions.
Have configure save you an environment setup script for future use by typing:
./Configure
(that was with no options, as opposed to ./Configure -build that you typed earlier).
You will see the following:
--- Geant4 Toolkit Installation ---
(setting environments for USER )
---------------------------------------------------
The Geant4 toolkit installation was found.
The files env.[c]sh will be copied to your current directory.
For setting Geant4 environments you should make:

source env.csh
or
env.sh
It will also check G4WORKDIR setting and set it to
your HOME if needed.
You can use these files also for further modifications
(adding your own environments).
---------------------------------------------------
Your directory C:/Geant4/geant4_9_4_p01 will now contain two scripts:
env.sh
and
env.csh
The Geant4 Work Directory
You have now built the Geant4 toolkit. If you have learned a little about Geant4, you will know that Geant4 is
not an application but rather a toolkit from which you can build any number of applications. So before you can
test Geant4, you need an example application.
You should create a new directory, outside of your Geant4 installation area, where you will keep your example
applications. This separation of spaces will help you avoid accidentally messing up your main Geant4
installation and will insure that if you eventually update your main Geant4 installation (for example when a
newer Geant4 release is available), your personal application work will not be disturbed.
Create a new directory for your work, and designate it as your G4WORKDIR.
For example, if you want your work to be in C:/g4work:
export G4WORKDIR=C:/g4work
Selecting an Example Application
You can try any of the Geant4 examples. Some suggested starting points are any of the Novice examples
C:/Geant4/geant4_9_4_p01/examples/novice
or a more complex example
C:/Geant4/geant4_9_4_p01/examples/extended/analysis/A01
Each example is described in a detailed README in the example's top level directory.
Whichever example you choose, copy it to your Geant4 work directory.
For example, you might end up with:
C:/g4work/A01
Configuring the Environment
Note that this step needs to be redone any time you start a fresh Cygwin window.
Type:
export G4WORKDIR=C:/g4work
source C:/Geant4/geant4_9_4_p01/env.sh
It will respond:
On this machine the G4SYSTEM=WIN32-VC
On this machine the G4INSTALL=c:/Geant4/geant4_9_4_p01
On this machine the G4LIB=c:/Geant4/geant4_9_4_p01/lib
On this machine the G4LEVELGAMMADATA=c:/Geant4/geant4_9_4_p01/data/PhotonEvaporation2.1
On this machine the G4RADIOACTIVEDATA=c:/Geant4/geant4_9_4_p01/data/RadioactiveDecay3.3
On this machine the G4LEDATA=c:/Geant4/geant4_9_4_p01/data/G4EMLOW6.19
On this machine the G4NEUTRONHPDATA=c:/Geant4/geant4_9_4_p01/data/G4NDL3.14
On this machine the G4ABLADATA=c:/Geant4/geant4_9_4_p01/data/G4ABLA3.0
On this machine the G4REALSURFACEDATA=c:/Geant4/geant4_9_4_p01/data/RealSurface1.0
On this machine the G4NEUTRONXSDATA=c:/Geant4/geant4_9_4_p01/data/G4NEUTRONXS1.0
On this machine the G4PIIDATA=c:/Geant4/geant4_9_4_p01/data/G4PII1.2
On this machine the CLHEP_BASE_DIR=C:/CLHEP
On this machine the CLHEP_INCLUDE_DIR=C:/CLHEP/include
On this machine the CLHEP_LIB_DIR=C:/CLHEP/lib
On this machine the CLHEP_LIB=CLHEP.lib
On this machine the G4VIS_BUILD_OPENGLWIN32_DRIVER=1
On this machine the G4VIS_USE_OPENGLWIN32=1
On this machine the XMFLAGS=
On this machine the XMLIBS=
On this machine the XMFLAGS=
On this machine the XAWFLAGS=
On this machine the XAWLIBS=
On this machine the G4LIB_BUILD_ZLIB=1
On this machine the G4LIB_USE_ZLIB=1
On this machine the G4LIB_BUILD_STATIC=1
Ignore any warning about:
MS-DOS style path detected: C:/Geant4/geant4_9_4_p01/env.sh...
Be sure not to accidentally use the other Linux forms of this command:
source C:/Geant4/geant4_9_4_p01/env.csh
or
cd C:/Geant4/geant4_9_4_p01/
./env.sh
Neither of these will give correct results in this Cygwin environment.
A further note about the environment setup scripts:
The env scripts do not set every environment variable that could be used by Geant4. They only set those
variables that you had declared to non-default values in the configure process. This works fine because any
variable that Geant4 does not find is assumed to be default. But if you are also setting some of your Geant4
environment variables elsewhere, such as in your Windows environment setup, or in your cygwin.bat file, you
can end up with inconsistent results. That is why you were strongly advised to make sure you had no pre-
existing Geant4 variables set before you began the Geant4 build.
Building an Example Application
Did you "Configure the Environment" as described above? Remember that you need to do this every time you
start a new Cygwin window.
Build your example by typing, the following. Be sure to use make rather than gmake.
cd $G4WORKDIR/A01
make
You will see output beginning with:
Making dependency for file A01app.cc ...
Making dependency for file src/A01PrimaryGeneratorMessenger.cc ...
Making dependency for file src/A01PrimaryGeneratorAction.cc ...
Making dependency for file src/A01PhysicsList.cc ...
Making dependency for file src/A01MuonPhysics.cc ...
And ending with:
Compiling A01app.cc ...
A01app.cc
Using global libraries ...
Linking A01app
... Done!
The complete output from the above command can be found in this same web directory as:
A01Make.txt
If you get an error such as:
c:\g4work\A01\src\A01AnalysisManager.cc : fatal error C1083: Cannot open compiler generated file:
'/cygdrive/c/g4work/tmp/WIN32VC/A01app/A01AnalysisManager.o':
No such file or directory
make: *** [/cygdrive/c/g4work/tmp/WIN32VC/A01app/A01AnalysisManager.o] Error 1
it probably means you used the wrong form of the work directory path when you defined your G4WORKDIR
variable. You used a form like "/cygdrive/c/g4work" when you need a form like "C:/g4work". Wipe out your
A01 directory, redefine G4WORKDIR and have another try.
If the build is successful, you will see the completed application file in your $G4WORKDIR directory such as:
$G4WORKDIR/bin/WIN32-VC/A01app.exe
Running
As always, if this is a fresh Cygwin window, configure it for Geant4 by typing:
export G4WORKDIR=C:/g4work
source C:/Geant4/geant4_9_4_p01/env.sh
To run your example, cd to the example's top level directory, such as:
cd $G4WORKDIR/A01
And from there, run the newly created executable:
$G4WORKDIR/bin/WIN32-VC/A01app
You will see a response that starts with:
*************************************************************
Geant4 version Name: geant4-09-04-patch-01 (18-February-2011)
Copyright : Geant4 Collaboration
Reference : NIM A 506 (2003), 250-303
WWW : http://cern.ch/geant4
*************************************************************
Visualization Manager instantiating with verbosity "warnings (3)"...
Visualization Manager initialising...
Registering graphics systems...
You have successfully registered the following graphics systems.
Current available graphics systems are:
ASCIITree (ATree)
DAWNFILE (DAWNFILE)
G4HepRep (HepRepXML)
G4HepRepFile (HepRepFile)
RayTracer (RayTracer)
VRML1FILE (VRML1FILE)
VRML2FILE (VRML2FILE)
gMocrenFile (gMocrenFile)
OpenGLStoredWin32 (OGL)
OpenGLImmediateWin32 (OGLI)
OpenGLStoredWin32 (OGLS)
OpenGLImmediateWin32 (OGLIWin32)
OpenGLStoredWin32 (OGLSWin32)
And ends with:
EMcalorimeterPhysical[0] EMcalorimeterLogical 1 CsI
cellPhysical[-1] cellLogical 0 CsI /EMcalorimeter
HadCalorimeterPhysical[0] HadCalorimeterLogical 1 Lead
HadCalColumnPhysical[-1] HadCalColumnLogical 1 Lead
HadCalCellPhysical[-1] HadCalCellLogical 1 Lead
HadCalLayerPhysical[-1] HadCalLayerLogical 1 Lead
HadCalScintiPhysical[0] HadCalScintiLogical 0 Scintillator /HadCalorimeter
Idle>
The complete output from the above command can be found in this same web directory as:
A01Run.txt
Make sure your output included a mention of the graphics system:
OpenGLStoredWin32 (OGL)
If this didn't show up, you have missed something in the above instructions.
Did you correctly answered the questions about OpenGL in the ./Configure -build procedure?
Did you get error messages during that procedure?
Did you follow the instructions in the above section, "Creating the setup script"?
Did you follow the instructions above about "As always, if this is a fresh Cygwin window, configure it for
Geant4 by typing..."?
If you still can't figure out why you don't have OpenGL, you can still proceed, but you will have to use some
other graphics driver. See some notes a little later in this document about how to use the HepRepFile driver.
From here, we'll assume you have OpenGL successfully loaded.
From the idle prompt, visualize the example by typing the following:
/vis/open OGL
/vis/drawVolume
An OpenGL window will appear and the example geometry will be drawn, as in:
If you have something odd about your OpenGL installation, it may be that you will get better results with a
slightly different version of the OpenGL driver:
/vis/open OGLI
/vis/drawVolume
/vis/viewer/flush
The difference is in whether or not OpenGL will use something called a "display list." Most users will not need
to try this, but there are so many different versions of Windows in use that we mention this option for those
who might need to try it. If you do use the OGLI form, remember to include /vis/viewer/flush
To add trajectories and hits to the visualization, and then run an event:
/vis/scene/add/trajectories
/vis/scene/add/hits
/run/beamOn 1
You will then see something like:
When you are finished with your Geant4 session, just type:
exit
For more details on using OpenGL for Geant4, see:
http://geant4.slac.stanford.edu/Presentations/vis/G4OpenGLTutorial/G4OpenGLTutorial.html
Here's another example. This one makes output go to a HepRep file, suitable for viewing in the HepRApp
HepRep Browser:
$G4WORKDIR/bin/WIN32-VC/A01app
/vis/open HepRepFile
/vis/drawVolume
/vis/viewer/flush
/vis/scene/add/trajectories
/vis/scene/add/hits
/run/beamOn 1
For more details on using HepRApp for Geant4, see:
http://geant4.slac.stanford.edu/Presentations/vis/G4HepRAppTutorial/G4HepRAppTutorial.html
Note: HepRApp and Geant4 do not have to run on the same machine. You can copy the .heprep file from the
Geant4 machine to the machine with HepRApp, or you can simply make the .heprep file visible from the web,
and let HepRApp pick it up via the url.
Also note that the .heprep file can be zipped to about 5 percent of original size and HepRApp can then read in
the zipped version (you don't need to unzip the file).
You now have Geant4 installed and have demonstrated a few examples using two different visualization
systems.
How to go back and change choices from./Configure -build
You can go back and re-run Geant4's ./Configure -build procedure at any time to change various options. In
general, this will not force a complete recompilation but will only rebuild those libraries that have changes.
Make sure to run ./Configure -build in a fresh session, one that doesn't have the G4WORKDIR environment
variable set. Otherwise this difference between your original build environment and your new one will trigger a
whole new Geant4 build in a whole new place.
After the build, do ./Configure (the version with no arguments that creates the env.sh and env.csh files) and, if
you are doing a multi-user installation, ./Configure -install
Remember that if you had needed to rename some other application's gmake.exe before your initial ./Configure
-build, you will need to do that again now.
Also note that even though you successfully rebuild Geant4, your user application will not take advantage of
the change unless you explicitly tell it to do so. The standard way to do this is to update the time stamp of your
application's main class before you rebuild the application. For example, use the "touch" command:
export G4WORKDIR=C:/g4work
source C:/Geant4/geant4_9_4_p01/env.sh
cd $G4WORKDIR/A01
touch A01app.cc
make
I hope these instructions have been helpful.
If you find any problems or can suggest corrections, please let me know.

Joseph Perl

SLAC Geant4 Team

1 March 2011